Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Windows Nt support

<< < (2/4) > >>

bluearms:
I am not c++ programmer, I just use c. So this may be not correct. But this c algorithm should work.
Basically windows 95 and nt does not support multiple monitors. Anyway, why C::B requires multiple
monitors support? There are many warys of getting single monitor geometry, if you ignore multiple
monitors.

+static HMONITOR APIENTRY (*MonitorFromWindowProc) (HWND, DWORD) = NULL;
+static BOOL APIENTRY (*GetMonitorInfoProc) (HMONITOR, LPMONITORINFO) = NULL;

void PlaceWindow(wxWindow *w, cbPlaceDialogMode mode, bool enforce)
{
+ int MultiMonOk = 1;
...
...
-   hMonitor = MonitorFromWindow((HWND) referenceWindow->GetHandle(), MONITOR_DEFAULTTONEAREST);
+  if (MonitorFromWindowProc) {
+    /* MonitorFromWindowProc already set */
+    hMonitor = (*MonitorFromWindowProc)((HWND) referenceWindow->GetHandle(),
MONITOR_DEFAULTTONEAREST);
+  } else {
+    /* check API availability */
+    MonitorFromWindowProc =
+    (HMONITOR APIENTRY (*) (HWND, DWORD))
+    GetProcAddress(GetModuleHandle("user32.dll"), "MonitorFromWindow");
+    if (MonitorFromWindowProc)
+      hMonitor = (*MonitorFromWindowProc)((HWND) referenceWindow->GetHandle(), MONITOR_DEFAULTTONEAREST);
+    else {
+       /* API not available, maybe Win95 or NT 3/4.  */
+       MultiMonOk = 0;
+    }
+  }
+  if (MultiMonOk) {
    mi.cbSize = sizeof(mi);
-  GetMonitorInfo(hMonitor, &mi);
+    if (GetMonitorInfoProc) {
+      (*GetMonitorInfoProc)(hMonitor, &mi);
+    } else {
+      GetMonitorInfoProc =
+      (BOOL APIENTRY (*) (HMONITOR, LPMONITORINFO))
+#ifdef UNICODE
+      GetProcAddress(GetModuleHandle("user32.dll"), "GetMonitorInfoW");
+#else
+      GetProcAddress(GetModuleHandle("user32.dll"), "GetMonitorInfoA");
+#endif
+      if (GetMonitorInfoProc) (*GetMonitorInfoProc)(hMonitor, &mi);
+      else {
+        /* not possible, unknown error */
+        goto genericRect;
+      }
+    }
    r = mi.rcWork;
+  } else {
+genericRect:
+    HWND hDesktop;
+    int rc;
+    hDesktop = GetDesktopWindow();
+    /*  if (hDesktop == NULL) criticalErrorExit(); */
+    rc = GetWindowRect(hDesktop, &r);
+    /* if (rc==0) error(); */
+  }

...

}

I think you should convert this to proper C++ version.
Insteadd of GetDesktopWindow(), you can use GetSystemMetrics with SM_CXSCREEN and SM_CYSCREEN (maybe). I have installed platform SDK and documentation includes all windows specific APIs.
I think this kind of runtime checking of API is used in many windows porting of unix programs like perl etc.
In test, windows rectangle's right bottom part returns 1 point right down the region. If resolution is 1024x768, then
returned point is {(0, 0), (1024, 768)}. Not {(0, 0), (1023, 767) }

TDragon:

--- Quote from: bluearms on January 14, 2007, 07:10:16 am ---Anyway, why C::B requires multiple
monitors support?
--- End quote ---
Because people with multiple monitors, such as myself, use Code::Blocks; and because C::B will not work correctly for people with multiple monitors unless they are explicitly taken into account.

stahta01:
I am working on a good patch for this issue, but I need people to test it.
Anyone want to test it?

Window 95 user
Window NT 4.0 user
Multi-monitor user

Tim S

bluearms:

--- Quote from: stahta01 on January 14, 2007, 11:35:42 am ---I am working on a good patch for this issue, but I need people to test it.
Anyone want to test it?

Window 95 user
Window NT 4.0 user
Multi-monitor user

Tim S

--- End quote ---

I have windows 95 and NT in the virtual pc to test software compatibility and to install some evalation purpose programs (If you install and uninstall many programs in main pc, your hard disk and registry will be get messy  :D). In that system, I usually use msys, visual studio 6, borland c++ 6, delphi 6 (to maintain small compiler system. Even with that my virtual image is getting large). If you upload compiled binary, I can use that. Anyway I need IDE in that systems  :).

stahta01:

--- Quote from: bluearms on January 14, 2007, 12:03:49 pm ---I have windows 95 and NT in the virtual pc to test software compatibility and to install some evalation purpose programs (If you install and uninstall many programs in main pc, your hard disk and registry will be get messy  :D). In that system, I usually use msys, visual studio 6, borland c++ 6, delphi 6 (to maintain small compiler system. Even with that my virtual image is getting large). If you upload compiled binary, I can use that. Anyway I need IDE in that systems  :).


--- End quote ---

OK, after I finish testing the patch I will upload the patch to Berlios.
Then, I will make an ANSI build for Win95/NT4.0.
I will upload that to a free file share site.
Tim S

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version