CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2003
    Posts
    5

    Question CreateWindow in win32 dll

    Hi,

    Can anyone show me an example how to CreateWindow in a win32 dll? Also please show me how you handle the message loop?

    thanks.

  2. #2
    Join Date
    Mar 2001
    Location
    Germany/Hannover
    Posts
    32
    in your dll-main @DLL_PROCESS_ATTACH you should start a thread with _beginthreadex() with a function somewhat like threadProc()

    in your threadProc() do the following:

    - define a WNDCLASS
    - register WNDCLASS
    - CreateWindow()
    - ShowWindow()
    - add your messageloop -> while(GetMessage...) at the end of the threadProc()

    - your WndProc() should be placed outsid the thread

    thats the way i always use ... hope it helps
    Last edited by RockNix; January 15th, 2003 at 08:38 AM.
    So far ... RockNix

    ---------------------------------------------
    Want some code about Threading,
    SerCOM, Subclassing .... ?

    Go for it - visit us on:
    www.klangwerker.de
    ---------------------------------------------

  3. #3
    Join Date
    Jan 2003
    Posts
    5
    Thanks very much.... it is working now.

  4. #4
    Join Date
    Aug 2006
    Posts
    3

    Re: CreateWindow in win32 dll

    Hi!

    I'm new on this. Can you give me all the example?
    I really need to show a window using an dll.

    Thanks,
    Sérgio Cardoso

  5. #5
    Join Date
    Jul 2006
    Posts
    97

    Re: CreateWindow in win32 dll

    Quote Originally Posted by scardoso
    Hi!

    I'm new on this. Can you give me all the example?
    I really need to show a window using an dll.

    Thanks,
    Sérgio Cardoso
    Here you go:
    http://www.pscode.com/vb/scripts/Sho...10097&lngWId=3
    Non-MFC example.
    Using .NET 2.0

  6. #6
    Join Date
    Aug 2006
    Posts
    3

    Re: CreateWindow in win32 dll

    Thanks for your help, Gecka.

    But i'm using a DLL, so it don't work. Do you have an example with DLL?

    Sérgio Cardoso

  7. #7
    Join Date
    Jan 2012
    Posts
    5

    Re: CreateWindow in win32 dll

    Hi San_Lee,
    Is it possible for you to share me with the code for the DLL and also the test exe code. I'm too trying with this item but no result.. Thanx,

  8. #8
    Join Date
    Sep 2011
    Posts
    75

    Re: CreateWindow in win32 dll

    I am also interested in this. I don't mean to hijack this thread but: What are the limitations of creating windows from a dll?Can I effectively run an entire multithreaded client application through a dll entry point?

    Does my question make no sense? I suck with this stuff.

  9. #9
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: CreateWindow in win32 dll

    Well, dll is just a piece of compiled code that dynamically gets loaded into process address space and linked with the process. After that it behaves like any other part of the program. Which naturally means that dll code can do anything the exe code can, including creating threads and windows, and windows in threads of course.

    See the sample in the post. You may completely ignore the semaphore stuff in the sample (sorry, the code's not mine, I just made it runnable.)
    Last edited by Igor Vartanov; February 3rd, 2012 at 01:37 AM.
    Best regards,
    Igor

  10. #10
    Join Date
    Sep 2011
    Posts
    75

    Re: CreateWindow in win32 dll

    So I can package a function like winMain into the dll and make it an exportable function? Or would I have an exported function that calls what is essentially in the body of winMain (not a call to winMain itself). Does the DLL need an entry point?

    Thanks

  11. #11
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: CreateWindow in win32 dll

    So I can package a function like winMain into the dll and make it an exportable function?
    You can.
    Or would I have an exported function that calls what is essentially in the body of winMain (not a call to winMain itself).
    In dll you can have an exported function that registers window class and/or creates window. I thought I already said that above: you can have in dll any code you can have in exe. Exported or not, this affects only way you link it.
    Does the DLL need an entry point?
    Every code dll must have an entry point. Resource-only dll may not.
    Last edited by Igor Vartanov; February 3rd, 2012 at 11:44 AM.
    Best regards,
    Igor

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

Featured