Jump to content
  • Advertisement
Sign in to follow this  
50p

[Win32 API] Creating classes (error when compiling)

This topic is 3404 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there. I moved from MFC to Win32 API because I think it's better (maybe not easier). I made a new dialog (in the dialog editor (VS2005)) and it has a ListControl (ListView) control and to add, remove, edit, etc. items from/to it in the code is a bit messy. So I decided to make a class for it so the code will be more clear and easier to use the control but, I get errors complaining about return data types and some others... I'll show you my class and please tell me why it's not compiling: http://50p.pastebin.com/m47296db3 I don't see anything wrong with the class itself -_-' It compile fine only if I use int, float, double, etc. but not BOOL, LPSTR, etc. why? Here are files that are included in main.cpp
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gl/gl.h>
#include <gl/glu.h>

#include <commctrl.h>

#include "resource.h"

#include "ListViewCtrl.h"

Share this post


Link to post
Share on other sites
Advertisement
Try to include windows.h in CListViewCtrl.h. Since it actually uses Windows types you need to have it included anyway.

In this case #pragma once might actually bite you. It is more to type, but try "real" header inclusion guards.

Share this post


Link to post
Share on other sites
Adding #include <windows.h> got rid of most of the errors but than I had issues with LVCOLUMN, so I added #include <commctrl.h> and it compiles just fine.

I thought that if I'll #include <windows.h> in main.cpp and than #include "ListViewCtrl.h" also in main.cpp than ListViewCtrl.h will have <windows.h> included as well (that's why I posted what I included in main.cpp) but I was wrong.

Thanks a lot.

EDIT:
BTW, does anyone know if there is a message sent when a window is created? I'm not talking about WM_CREATE because it's triggered before the window is shown.
In C# it's OnLoad event but I don't know what it is in Win32 API. Basically, I want to display a new window which will be used to control what's going on in the OpenGL window. So I'd like to display the new window "on top" of the OpenGL window. To do this I used DialogBox() but when I use it, the new window is created but the "main" one isn't, until I close the "sub window". Maybe I should use CreateWindow instead but how would I use the dialog box's ID that is in .rc file?

Share this post


Link to post
Share on other sites
WM_CREATE is the closest thing to OnLoad for non-dialog HWNDs.

DialogBox opens the dialog modal, this doesn't sound like the behaviour you need. You can use the CreateDialog macro:

hwndDialog = CreateDialog( hInstance, MAKEINTRESOURCE( ID_FROM_DIALOG_RESOURCE ), hwndMain, MyDialogProc );

A dialog sends the WM_INITDIALOG message to its DlgProc, you can use this to do further initialisation.

Share this post


Link to post
Share on other sites
Thanks. That worked well!
Do you maybe know if it's possible to keep that dialog box always on top of its parent? I don't want it to be always on top of every system windows but just its parent (main window of my application).

Thanks in advance!

Share this post


Link to post
Share on other sites
I'm not sure if I understand you. Do you want a tool window behaviour as in the window is visible while your app is active, but hides, if your app is not active?

If so, you have to implement that yourself. Check WM_ACTIVATE_APP in your main window proc and call ShowWindow with the HWND of the dialog accordingly.

Share this post


Link to post
Share on other sites
AFAIK there is no WM_ACTIVATE_APP but WM_ACTIVATE. Anyway, I tried to ShowWindow with WM_ACTIVATE message but it doesn't seem to work at all. I'd like to achieve this:
http://img40.imageshack.us/img40/2395/mainwndandtoolswnd.png

So that even if my main ("GL WINDOW!") is active (focused) the Tools window would always be on top of that main, as you can see on the screenshot.
But I get this:
http://img42.imageshack.us/img42/1395/mainwndandtoolswnd2.png

So it means that WM_ACTIVATE is not called or ShowWindow doesn't show the Tools window on top of the main window. I tried many SW_xxx to show the window but none of them worked the way I wanted. I'd like the tools window to be on top of main window but if the main window is active (focused) than the Tools window would not active (of course) and that would mean the window would be "grayed" (non active window).

Share this post


Link to post
Share on other sites
Ah, i understand now. Sorry for the typo.

You could also try SetWindowPos with setting the z order of the tool window above the main window and SWP_NOMOVE | SWP_NOSIZE set. Do check the flags from WM_ACTIVATEAPP.

That's one of the things that MFC handles nicely. All the tool windows get an active caption (although they're technically are not) and are auto-hidden when the main window loses focus.
This functionality is a monstrous hack. You can look at Catch 22's tutorial, he explains how to do this manually: Clicky

Share this post


Link to post
Share on other sites
It's not possible or you guys don't know what I mean or you don't know how to achieve it :P

I tried: ShowWindow( hToolsWnd, INT )
Where INT was from 1 to 18. Even though there are only 11 values possible for the 2nd param, SW_SHOWNORMAL to SW_MAX (1-11).


http://prdownloads.sourceforge.net/crayzedsgui/CELayoutEditorSetup-0.6.2.exe?download
This is a link to CEGUI Layout Editor which works the way I want. If any of you could download it and see what I mean I'd be grateful.

Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!