User forums > Help
Weird WinAPI problem
henniez-swisswater:
I have twice the same code. once it works fine the other one doesn't work. the code is supposed to show a window with a static text (created with CreateWindow("STATIC","blabla",...)). the reason for me having twice the same code, is that that I worte one from scratch (not working) and the other one is generate by code::blocks. the code::blocks one works, so I copied the working code, generated by code::blocks, and I overwrote my code. Here coms the strange thing, it still doesn't work. It is exactly the same code. Is it possible than some kind of project setting can cause this problem?
regards
webwraith:
Do you have both pieces of code in the same project? If not, perhaps you should check the build options of the non-working code.
Also, you just say that the code isnt working, how do you mean?
Is it not compiling? compiling, but not linking? What are the error messages (if any)?
henniez-swisswater:
o sry for that. it compiles but the static text is nowhere (the non-working one). and yeah they are in two different projects.
webwraith:
OK, I'm not quite sure I follow you. what do you mean by static text?
CreateWindow takes two character arrays, one is the name of your previously registered class (i.e.;the lpszClassName member of WNDCLASS structure), this must be the same as your registered window class otherwise Windows will be looking for a class that doesn't exist.
Thoe other character array is the 'caption' of the window, or the text that appears in the titlebar. This can be anything you like, but won't put anything into the client area (the main area of the window).
If you want the equivalent of an error message-type window, use MessageBox() instead. otherwise you're looking at window controls, and there are others out there much more knowledgable about those than I. Your best bet is to invest in a decent book on Win32 api programming
TDragon:
--- Quote from: webwraith on March 06, 2006, 05:58:28 pm ---CreateWindow takes two character arrays, one is the name of your previously registered class (i.e.;the lpszClassName member of WNDCLASS structure), this must be the same as your registered window class otherwise Windows will be looking for a class that doesn't exist.
--- End quote ---
Or it may be one of the predefined class names, such as "COMBOBOX" or "STATIC".
--- Quote ---Thoe other character array is the 'caption' of the window, or the text that appears in the titlebar. This can be anything you like, but won't put anything into the client area (the main area of the window).
--- End quote ---
...unless you're creating a control window as a child window of the main window, or any of a number of similar scenarios.
--- Quote ---otherwise you're looking at window controls, and there are others out there much more knowledgable about those than I.
--- End quote ---
Indeed...
henniez-swisswater: The Win32 API is a fickle mistress. When I'm forced to use it, I tend to keep the MSDN Library open for reference to any functions I use. When problems like yours show up, it's usually due to some obscure constraint on a Win32 function.
Fortunately, I can usually make use of wxWidgets, which actually makes GUI programming fun.
Good luck...
Navigation
[0] Message Index
[#] Next page
Go to full version