|
However, how do I get the HINSTANCE of a newly created window? You see, my window API wrapper, creates a window and obtains a HWND from CreateWindowEx. But as I create children in this window, to their CreateWindowEx I also have to specify a HINSTANCE. And from where exactly will I find out the HINSTANCE of the first window that I created, considering that I did not retrieve it via WinMain since I do not have a WinMain (I have a WndProc only). Can I specify the same HINSTANCE as I specified for the parent? Or should I do in another way? Any ideas?
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
The HINSTANCE you pass to CreateWindow(Ex) should be:
- The HINSTANCE of the module that called RegisterClass for the desired window class (the one you're creating); or if the CS_GLOBALCLASS class style is used,
- Whatever you like (I'd use NULL in this case).
All of the pre-registered window classes like "EDIT" and "STATIC" use the CS_GLOBALCLASS class style.
Steve
|
|
|
|
|
1. So I can specify NULL for all of these?
Button The class for a button.
ComboBox The class for a combo box.
Edit The class for an edit control.
ListBox The class for a list box.
MDIClient The class for an MDI client window.
ScrollBar The class for a scroll bar.
Static The class for a static control.
2. But still, how can I get the HINSTANCE of a window that I created using CreateWindowEx using a simple class that I created too using RegisterClassEx.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Axonn Echysttas wrote: 1. So I can specify NULL for all of these?
Yes.
Axonn Echysttas wrote: 2. But still, how can I get the HINSTANCE of a window that I created using CreateWindowEx using a simple class that I created too using RegisterClassEx.
Two choices here:
1. When you call RegisterClass(Ex) use the CS_GLOBALCLASS style. If you do this you can pass NULL for your own classes. This is the more dangerous option because as the class is global you run the risk of name clashes.
2. When you call RegisterClass(Ex) pass the HINSTANCE of the you EXE/DLL and use the same HINSTANCE when calling CreateWindow(Ex) . In this case it is the HINSTANCE /class name pair that identify the window class. Typically the HINSTANCE of the module that calls RegisterClass(Ex) is used.
Steve
-- modified at 9:29 Thursday 19th January, 2006
I misunderstood (2):
A HINSTANCE identifies a module (an .EXE or DLL). I'm not sure if you can get the HINSTANCE of a class from a HWND .
|
|
|
|
|
Yeap. Ok. It's all clear now. Thank you a lot. My final decision is that I will use the HINSTANCE of the EXE/DLL all over the place, rather than using global.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
|
in the header file it says,
<br />
typedef UINT WPARAM;<br />
typedef LONG LPARAM;<br />
typedef LONG LRESULT;
so WPARAM can be anything as long as you dont want to pass a negative values,
LPARAM can take negative values,
Also both are used for polymorphic values, so anything from number of trees to pointers can go there
I generally use LPARAM for pointers only.
-Prakash
|
|
|
|
|
The guideline is indeed tied to the event. That's the point, a generate purpose param that can hold whatever the event wants to pass.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
HWND is a handle, so you dont know what value it would hold, so i would put that on LPARAM.
-Prakash
|
|
|
|
|
I am not sure if this still hold true, maybe someone else knows, but the WPARAM used to get trunated to the lower 16 bits when it passed through some message filters. Therefore, I am careful, still, to only pass 16-bit or less values in WPARAM. LPARAM never had any such issues.
|
|
|
|
|
Blake Miller wrote: but the WPARAM used to get trunated to the lower 16 bits when it passed through some message filters
Can you suggest message filters. I would like to know.
So in your opinion what should I do for consistency sake. A few guidelines from you would be helpful.
Or maybe what do you do normally.
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I am not sure which message filters would truncate WPARAM to 16 bits. However, that is WHY it was originally called WPARAM - because it was limited to being a WORD (16-bits).
I limit WPARAM in my work to 16 bits. I use LPARAM full 32 bits.
Usually I do not try to pass pointers or much data through the messages. I pass messages as notifications only between 'subsystems' and rely upon data retrieval function calls to be made to collect the data itself. Some programmers rely upon SendMessage to pass pointers to data via the message queue between subsystems, but that ends up being more trouble to synchyronize with the sending and receiving windows' other activities and other events occuring in a multithreaded envionment. Sure I guess it works okay if the application has a signle thread, but that is not the type of code I am typically writing anyway.
|
|
|
|
|
Hello there,
I am relativly new to C++ and am currently programming for windows in Visual C++. What I want to know is this:
I created a program in which a user enters commands and these commands are compared to functions stored in a seperate .cpp file. This file is in the same folder as the executable but is not part of the solution. Is there a way for the user to enter a command such as 'update' and the program will seek an updated version of the command file and download it from a specified server? i can get everything to work, but I do not know even where to begin will this update feature.
ALL YOUR BASE ARE BELONG TO MICROSOFT!
Demonware Studios Leader
|
|
|
|
|
Do some form of HHTP reuest against your server to see if a 'newer' file exists. Then download the new file as 'text' so it can pass through HTTP and the firewall, then replace your old command file with the new one.
|
|
|
|
|
Thank you
ALL YOUR BASE ARE BELONG TO MICROSOFT!
Demonware Studios Leader
|
|
|
|
|
I'm working on a CEdit derived class that requires that I put a bit of text in the window on creation. I'm doing this in PreSubclassWindow, which may or not be the right place for it but it works. The problem I'm running into is the cursor positioning. If I use SetSel(0,0) in PreSubclassWindow the text ends up being completely highlighted. For the moment I've included a SetSel in the SetFocus handler. But this isn't practical long term. Without any attempt at setting the position selector I still get a completely highlighted edit space.
Where would be the best place to set the original position?
Thanks,
Lilith
|
|
|
|
|
|
Could you please give me some idea on the best C++ compiler available for an Windows XP Pro system? I'd like to do some simple tasks that might include graphics. Are there free compilers that I should try? Thank you.
|
|
|
|
|
Please post this in the Lounge[^] You will get more replies. This is the visual c++ forum.
Aljechin Alexander
|
|
|
|
|
|
I'm sorry to contradict you but I found that Dev-cpp is plain crap (to be polite ). It has too many bugs, it is slow, the debugger is totally unusable, the tabulations management (when you go to a new line) makes you loose more time than it makes you gain, the IntelliSense is slow and makes your program 'hang' during the time it searches for the class members, ...
Compared to Visual Studio, there is just simply no comparison possible. It is a completely different product.
-- modified at 3:45 Thursday 19th January, 2006
PS: this is not to take as an 'aggressive' post . I'm just describing my own experience with Dev-cpp
|
|
|
|
|
Yeah you are right. But he asked for free compilers to try out. There is no comparison with VS.
Cedric Moonen wrote: I'm sorry to contradict
Feel free. That's what we are here for. To kick and to get kicked.
Cedric Moonen wrote: PS: this is not to take as an 'aggressive' post . I'm just describing my own experience with Dev-cpp
My experience was much better.
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
The best is undoubtedly VC++2005, it will let you do GDI, GDI+, DirectX, and WPF in the not too distant future.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
this is a Visual C++ forum buddy, which means that almost here is using VC6, VC2002/2003 and/or VC2005...
if you're looking for something free, then don't ask this here. may the lounge help you, otherwise search for another site which is not dedicated to Microsoft technology
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|