If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: [win32] - creating controls using class's

Originally Posted by VictorN

Then debug your code step-by-step to see what and where goes wrong.
And don't forget to call GetLastError after anyof the Windows API functions you are using has failed!

i tested with windows application and the label is showed.. great. now i must connect the label with a message loop:
SetWindowLong( GetParent(hwnd), GWL_WNDPROC,(LRESULT) WndProc);//the WndProc is the message loop
but seems that i mistake several things
can you advice me please?

Re: [win32] - creating controls using class's

Creating windows with a class of 'STATIC' etc doesn't require you to provide a 'wndproc' - these classes already have their own. You only need to do this with classes such as 'STATIC' if you are sub-classing the window. The third argument of SetWindowLong is of type LONG and not of type LRESULT. The first parameter is the handle of the window for which you want to change the value - and not its parent.

All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

Re: [win32] - creating controls using class's

Originally Posted by 2kaud

Creating windows with a class of 'STATIC' etc doesn't require you to provide a 'wndproc' - these classes already have their own. You only need to do this with classes such as 'STATIC' if you are sub-classing the window. The third argument of SetWindowLong is of type LONG and not of type LRESULT. The first parameter is the handle of the window for which you want to change the value - and not its parent.

i'm doing a class label control(with windows messages). so the window message loop must be inside the class... but i never used the these function for connect it with that procedure... please tell me more for i fix the problem

Re: [win32] - creating controls using class's

... and where's the message pump for the windows messages? Standard controls (such as static, edit etc) don't use message loops (unless you are sub-classing the control). If you are trying to create your own window, then you need to create and register a class and then create a window from this class. Windows programing assumes that things are done how they are expected to be done - and not how you might want to do them.

All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

Re: [win32] - creating controls using class's

Originally Posted by 2kaud

... and where's the message pump for the windows messages? Standard controls (such as static, edit etc) don't use message loops (unless you are sub-classing the control). If you are trying to create your own window, then you need to create and register a class and then create a window from this class. Windows programing assumes that things are done how they are expected to be done - and not how you might want to do them.

Re: [win32] - creating controls using class's

Originally Posted by Cambalinho

i'm doing a class label control(with windows messages). so the window message loop must be inside the class...

What class? Control class never incorporates message pump. Message queue is owned by a thread, so there must be a single pump per thread servicing all the controls created in the context of the thread.

You're evidently lack of very basic knowledge of the way how window messages get processed in Windows, and trying to put this into OO paradigm makes the things be even worse.

Re: [win32] - creating controls using class's

I agree with Igor.

You shouldn't try and place an OO wrapper around the Windows API unless you know the Windows API. If you don't know how to put together a non-OO Win32 API program, then it makes absolutely no sense to try and place an object-oriented wrapper around the API.

This also applies to any API in general. To write object oriented wrappers around any API, whether it is Windows API, ODBC, TWAIN, etc. requires that you know, practically on an advanced level, the API you're trying to wrap.

Re: [win32] - creating controls using class's

what i'm doing wrong?

Not understanding how basic Windows code works. The main() program (which is usually winmain() for a windows program) essentially consists of registering a windows class, creating the main window and then the message pump. Everything else is then done as part of wndproc() in response to messages received. There is only one message pump per thread - not one per c++ class/windows class. Trying to put an OO wrapper around the Windows API is non-trivial. Why do you want to do this? If you don't want to use Windows APIs directly, why not use readily available windows libraries or frameworks?

when you understand all of this, then you'll be in a position to produce an OO wrapper for the Windows API.

Why bother?

All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

Re: [win32] - creating controls using class's

The case is activated. It's just that its going to the default: section.

What is the value of msg? Have the MessageBox show msg and then you will see what messages you are receiving. They are defined in winuser.h .

For a control, you wouldn't normally process WM_CLOSE and WM_DESTROY.

All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/