MCPcopy Create free account
hub / github.com/TASEmulators/fceux / CalcSubWindowPos

Function CalcSubWindowPos

src/drivers/win/window.cpp:3298–3335  ·  view source on GitHub ↗

Push the window away from the main FCEUX window

Source from the content-addressed store, hash-verified

3296
3297// Push the window away from the main FCEUX window
3298POINT CalcSubWindowPos(HWND hDlg, POINT* conf)
3299{
3300 POINT pt; // dialog position
3301 RECT wR, dR; // Window rect, dialog rect
3302
3303
3304 // Try to calc the default position, it doesn't overlap the main window and ensure it's in the screen;
3305 GetWindowRect(hAppWnd, &wR);
3306 GetWindowRect(hDlg, &dR);
3307
3308 pt.x = wR.left;
3309 pt.y = wR.top;
3310
3311 LONG wW = wR.right - wR.left; // window width
3312 LONG dW = dR.right - dR.left; // dialog width
3313
3314 if (pt.x + wW + dW < GetSystemMetrics(SM_CXSCREEN))
3315 pt.x += wW; // if there is enough place for the dialog on the right, put the dialog there
3316 else if (pt.x - dW > 0)
3317 pt.x -= dW; // otherwise, we check if we can put it on the left
3318
3319 // If the dialog has a configured window position, override the default position
3320 if (conf)
3321 {
3322 LONG wH = wR.bottom - wR.top;
3323 // It is overrided only when the configured position is not completely off screen
3324 if (conf->x > -wW * 2 || conf->x < wW * 2 + GetSystemMetrics(SM_CXSCREEN))
3325 pt.x = conf->x;
3326 if (conf->y > -wH * 2 || conf->y < wH * 2 + GetSystemMetrics(SM_CYSCREEN))
3327 pt.y = conf->y;
3328 }
3329
3330 // finally set the window position
3331 SetWindowPos(hDlg, NULL, pt.x, pt.y, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
3332
3333 // return the calculated point, maybe the caller can use it for further.
3334 return pt;
3335}
3336
3337static bool IsInputLegal(IsLetterLegalProc proc, int index, char letter)
3338{

Callers 7

MemWatchCallBFunction · 0.85
HeaderEditorProcFunction · 0.85
CheatConsoleCallBFunction · 0.85
GGConvCallBFunction · 0.85
DlgLuaScriptDialogFunction · 0.85
RamWatchProcFunction · 0.85
RamSearchProcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected