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.
Printable View
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.
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
Thanks very much.... it is working now.
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:Quote:
Originally Posted by scardoso
http://www.pscode.com/vb/scripts/Sho...10097&lngWId=3
Non-MFC example.
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
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,
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.
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.)
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
You can.Quote:
So I can package a function like winMain into the dll and make it an exportable function?
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.Quote:
Or would I have an exported function that calls what is essentially in the body of winMain (not a call to winMain itself).
Every code dll must have an entry point. Resource-only dll may not.Quote:
Does the DLL need an entry point?