B
Bern McCarty
I am trying to figure out how to create a windows form such that the
underlying native window is of a custom windows class of my choosing. This
should allow me to, among other things, specify that I want some extra space
in the window so that I can use SetWindowLongPtr/GetWindowLongPtr on the
underlying HWND. I have some native code that I'm hoping to leverage that
wants to use GetWindowLongPtr() on the window.
Firstly, is this feasible? The documentation seems to imply that it is. It
would stand to reason that there might be some constraints on you when
trying to do this but there are none spelled out anywhere that I can see. I
get the following run-time error when trying to create my winform:
An unhandled exception of type 'System.ComponentModel.Win32Exception'
occurred in system.windows.forms.dll
Additional information: Invalid window class name.
Am I supposed to NOT pass the name of an already registered windows class?
I ask because NativeWindow.WindowClass.RegisterClass() appears in my stack
at the time of the exception:
char* cmdLineP = 0x00251f1d, __int32 cmdShow = 0x5, void* exitFunc =
<undefined value>) Line 20747 C++
System.Windows.Forms.NativeWindow.WindowClass.RegisterClass() + 0x2c2
bytes
System.Windows.Forms.NativeWindow.WindowClass.WindowClass(string className
= "MStnChild", int classStyle = 0x8) + 0x28 bytes
System.Windows.Forms.NativeWindow.WindowClass.Create(string className =
"MStnChild", int classStyle = 0x8) + 0xfe bytes
System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreatePa
rams cp = {System.Windows.Forms.CreateParams}) + 0x108 bytes
System.Windows.Forms.Control.CreateHandle() + 0x1bb bytes
System.Windows.Forms.Form.CreateHandle() + 0x15d bytes
System.Windows.Forms.Control.get_Handle() + 0x34 bytes
Bentley.Mstn.Nonport.WinForms.BaseWinForm.BaseWinForm(mswindow*
__unnamed000 = 0x10fb0c60, System.Windows.Forms.CreateParams __unnamed001 =
0x0022c068) Line 59 + 0xa bytes C++
Yet, when I don't register the window class I get:
An unhandled exception of type 'System.ComponentModel.Win32Exception'
occurred in system.windows.forms.dll
Additional information: Invalid window class name.
If using custom windows classes underneath a winform is feasible, does
anyone have an sample code showing how to do it right?
underlying native window is of a custom windows class of my choosing. This
should allow me to, among other things, specify that I want some extra space
in the window so that I can use SetWindowLongPtr/GetWindowLongPtr on the
underlying HWND. I have some native code that I'm hoping to leverage that
wants to use GetWindowLongPtr() on the window.
Firstly, is this feasible? The documentation seems to imply that it is. It
would stand to reason that there might be some constraints on you when
trying to do this but there are none spelled out anywhere that I can see. I
get the following run-time error when trying to create my winform:
An unhandled exception of type 'System.ComponentModel.Win32Exception'
occurred in system.windows.forms.dll
Additional information: Invalid window class name.
Am I supposed to NOT pass the name of an already registered windows class?
I ask because NativeWindow.WindowClass.RegisterClass() appears in my stack
at the time of the exception:
void* hPrevInst = <undefined value>, char* programName = <undefined value>,win32Intface_winMainStartFromForeignExecutable(void* hInst = 0x00400000,
char* cmdLineP = 0x00251f1d, __int32 cmdShow = 0x5, void* exitFunc =
<undefined value>) Line 20747 C++
System.Windows.Forms.NativeWindow.WindowClass.RegisterClass() + 0x2c2
bytes
System.Windows.Forms.NativeWindow.WindowClass.WindowClass(string className
= "MStnChild", int classStyle = 0x8) + 0x28 bytes
System.Windows.Forms.NativeWindow.WindowClass.Create(string className =
"MStnChild", int classStyle = 0x8) + 0xfe bytes
System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreatePa
rams cp = {System.Windows.Forms.CreateParams}) + 0x108 bytes
System.Windows.Forms.Control.CreateHandle() + 0x1bb bytes
System.Windows.Forms.Form.CreateHandle() + 0x15d bytes
System.Windows.Forms.Control.get_Handle() + 0x34 bytes
Bentley.Mstn.Nonport.WinForms.BaseWinForm.BaseWinForm(mswindow*
__unnamed000 = 0x10fb0c60, System.Windows.Forms.CreateParams __unnamed001 =
0x0022c068) Line 59 + 0xa bytes C++
Yet, when I don't register the window class I get:
An unhandled exception of type 'System.ComponentModel.Win32Exception'
occurred in system.windows.forms.dll
Additional information: Invalid window class name.
If using custom windows classes underneath a winform is feasible, does
anyone have an sample code showing how to do it right?