Results 1 to 4 of 4

Thread: Creating a window by using the API

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Creating a window by using the API

    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; Aug 22nd, 2014 at 09:52 AM. Reason: Cleaned the code and fixed some bugs.

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Creating a window by using the API

    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)

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Creating a window by using the API

    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 02:45 PM.

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Creating a window by using the API

    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)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width