Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] Small GUI Error

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Sat Sep 20, 2008 11:54 am    Post subject: [C++] Small GUI Error Reply with quote

When I run my newly coded dialog, it appears without a background, title bar, etc. I'm using
Code:
ICC_STANDARD_CLASSES
so I don't know why they don't show up.


Pic:

.cpp
Code:

#include <windows.h>
#include <tchar.h>
#include <commctrl.h>
#include "resource.h"

#pragma comment (lib, "comctl32.lib")

BOOL DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
        case WM_CLOSE:
        case WM_DESTROY:
            EndDialog(hDlg, 0);
            break;
    }
    return TRUE;
}

BOOL WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
{
    INITCOMMONCONTROLSEX Init;
    Init.dwSize = sizeof(INITCOMMONCONTROLSEX);
    Init.dwICC  = ICC_STANDARD_CLASSES;
    InitCommonControlsEx(&Init);
   
    // Change "IDD_DIALOG1" to the name of the dialog you made in the .rc
    DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DlgProc);
    return TRUE;
}
 


.h

Code:

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by resource  file.rc
//
#define IDD_DIALOG1                     101
#define IDC_CHECK1                      1001

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1002
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

 


.rc
Code:

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_DIALOG1 DIALOGEX 0, 0, 311, 186
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,197,165,50,14
    PUSHBUTTON      "Cancel",IDCANCEL,254,165,50,14
    CONTROL         "CheckBox",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,113,77,46,28
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
    IDD_DIALOG1, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 304
        TOPMARGIN, 7
        BOTTOMMARGIN, 179
    END
END
#endif    // APSTUDIO_INVOKED

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

 




Or just look at the whole project [MediaFire(http://www.mediafire.com/?jtyymhlghxu)]




tl;dr Dialog background not showing up; Need help.


<__________________________________________________________>
Also: Why the hell is a .dll from Internet Download Manager involved when compiling?


_________________
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Sat Sep 20, 2008 1:49 pm    Post subject: Reply with quote

Try adding

Code:
default:
         return DefWindowProc(hwnd,msg,wParam,lParam);

to your case.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sat Sep 20, 2008 2:34 pm    Post subject: Re: [C++] Small GUI Error Reply with quote

manc wrote:
Also: Why the hell is a .dll from Internet Download Manager involved when compiling?
Your DLM probably hooks every process to manage all the DLs thru it or something? Uninstall your current one and use a proper DLM like wxDownloadFast: http://dfast.sourceforge.net/ . Free and everything. Oh yeh, and isn't that output from debug, not the compiler?
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Sat Sep 20, 2008 5:21 pm    Post subject: Reply with quote

HolyBlah wrote:
Try adding

Code:
default:
         return DefWindowProc(hwnd,msg,wParam,lParam);

to your case.




Code:
hwnd
and
Code:
msg
are undeclared identifiers


Also Jani, you're right thats debug my bad. And thanks for reference to the new download manager.

_________________
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Sep 20, 2008 5:23 pm    Post subject: Reply with quote

Just for some clarification:
hDlg and uMsg* and btw, you use DefDlgProc for Dialogs.

_________________
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Sat Sep 20, 2008 5:44 pm    Post subject: Reply with quote

So lurc, youre saying it should be like this?

Code:

default:
         return DefDlgProc(hDlg , uMsg, wParam, lParam);

_________________
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Sep 20, 2008 5:45 pm    Post subject: Reply with quote

I don't think its needed, but yes that's how it would be used.
_________________
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Sat Sep 20, 2008 5:53 pm    Post subject: Reply with quote

Ouch, almost worked...but then


Unhandled Error exception and shit...



Beyond my comprehension
Fucccccccccccccccccccccccccccccccck

_________________
Back to top
View user's profile Send private message
Fuzz
Grandmaster Cheater
Reputation: 0

Joined: 12 Nov 2006
Posts: 531

PostPosted: Sat Sep 20, 2008 6:48 pm    Post subject: Reply with quote

Make GUI's teh old fashion way.
_________________
Back to top
View user's profile Send private message AIM Address
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Sep 20, 2008 7:33 pm    Post subject: Reply with quote

manc wrote:
Ouch, almost worked...but then


Unhandled Error exception and shit...



Beyond my comprehension
Fucccccccccccccccccccccccccccccccck


Well, look where it breaks.
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Sun Sep 21, 2008 5:32 am    Post subject: Reply with quote

manc wrote:
Ouch, almost worked...but then


Unhandled Error exception and shit...



Beyond my comprehension
Fucccccccccccccccccccccccccccccccck


It's because DefDlgBox() calls DlgProc() which calls DefDlgBox()... you get the idea.

From MSDN:
Code:
The DefDlgProc function must not be called by a dialog box procedure; doing so results in recursive execution.


Bamn. Stack overflow.
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Sun Sep 21, 2008 7:03 am    Post subject: Reply with quote

For the DlgProc: when you handle the message, you should return true, and when you don't process the message and you want to let windows handle it, you should return false.
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Sun Sep 21, 2008 12:30 pm    Post subject: Reply with quote

slovach wrote:


Well, look where it breaks.


0% Experience/Knowledge with/about debugging/breakpoints =\



tombana wrote:
For the DlgProc: when you handle the message, you should return true, and when you don't process the message and you want to let windows handle it, you should return false.


So, you mean like:

Code:
BOOL DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
      default:
         return DefDlgProc(hDlg , uMsg, wParam, lParam)
         return FALSE;
     
        case WM_DESTROY:
            EndDialog(hDlg, 0);
            break;
         return TRUE;
    }
   


?????



Fuzz wrote:
Make GUI's teh old fashion way.


Old fashion way being...?

_________________
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Sun Sep 21, 2008 12:41 pm    Post subject: Reply with quote

manc wrote:

So, you mean like:

Code:
BOOL DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
      default:
         return DefDlgProc(hDlg , uMsg, wParam, lParam)
         return FALSE;
     
        case WM_DESTROY:
            EndDialog(hDlg, 0);
            break;
         return TRUE;
    }
   


No. When you handle the message like you handled the destroy message, you return true, that's allright. But when you don't handle the message, like your default case, you shouldn't call DefDlgProc, but you should just return false and then windows will call the DefDlgProc for you.

One more thing: I think you need to have the 'default' case at the bottom, below the other case's, but I'm not sure.

manc wrote:
Old fashion way being...?

I think he means CreateWindow or CreateWindowEx
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Sun Sep 21, 2008 1:01 pm    Post subject: Reply with quote

Oh ok, so


Code:
BOOL DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
   
     
        case WM_DESTROY:
            EndDialog(hDlg, 0);
            break;
         return TRUE;

  default:
        return FALSE;
    }

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites