The attached code (Create Window.zip) demonstrates how to use the CreateWindowEx API function to create a window and controls inside it.
The attached code (Create Window.zip) demonstrates how to use the CreateWindowEx API function to create a window and controls inside it.
Last edited by Peter Swinkels; Nov 17th, 2012 at 01:39 PM.
Nice demo!
However, for .hbrBackground = COLOR_BTNFACE to display as intended, MSDN says "the value 1 must be added to the chosen color".
The window title couldn't be set properly even though the algorithm looks alright...
The test on GetMessage's return value correctly follows MSDN's recommendation.![]()
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
Thanks for the reply. I fixed the hbrBackground property assignment (See my first post in this thread for the code.) I can't find anything wrong with the code that sets the new window title. What version of Windows are you using?
I'm using Microsoft Windows 7 Home Premium 64 bit.
Last edited by Peter Swinkels; Nov 17th, 2012 at 01:45 PM.
I tested your code on Win XP Pro SP2.
I tried it again and it turns out that adding a manifest (be it compiled or in the IDE) causes the Edit control to misbehave. I have yet to pinpoint the exact problem, but it seems the GetWindowText routine (which uses SendMessageA) doesn't work properly with the Edit control from comctl32.dll. I often use Unicode APIs in conjunction with manifests which is why I've never encountered this issue before. However, your code do perform as expected when not using a manifest.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)