Hi all,
I'm posting in response to a previous thread I had regarding Win32 dialogs not behaving properly. I fixed that, but now there's another problem.
The dialogue loads fine at startup, and the OK button I put in works. But the tab button, despite working in the resource editor, doesn't work. It just makes the standard Windows XP system sound and the cursor won't move to the next textbox.
Also, the X button on the toolbar up top won't work. I can click on it, it goes down, but doesn't close the dialogue. I've got the code for the whole app thus far here:
#include <iostream>
#include <windows.h>
#include "resource.h"
HWND LogonBox;
MSG MsgPump;
BOOL CALLBACK LogonProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nShowCmd)
{
CreateDialog(hInstance,MAKEINTRESOURCE(ICARUS_LOGONFORM),LogonBox,(DLGPROC)LogonProc);
while( GetMessage(&MsgPump, NULL, 0, 0) )
{
TranslateMessage(&MsgPump);
DispatchMessage(&MsgPump);
}
return MsgPump.wParam;
}
BOOL CALLBACK LogonProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
break;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case LOGONFORM_LOGON:
PostQuitMessage(0);
break;
}
}
break;
case WM_DESTROY:
PostQuitMessage(0);
case WM_CLOSE:
EndDialog(LogonBox,TRUE);
break;
default:
return FALSE;
}
return TRUE;
}
Here's resource.h:
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by LogonForm.rc
//
#define ICARUS_LOGONFORM 101
#define LOGONFORM_USERNAME 1000
#define LOGONFORM_PASSWORD 1001
#define LOGONFORM_LOGON 1003
#define LOGONFORM_FORGOTPASSLINK 1005
#define LOGONFORM_NEWACCLINK 1006
// 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 1007
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
And here's LogonForm.rc:
//Microsoft Developer Studio 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.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
ICARUS_LOGONFORM DIALOG DISCARDABLE 0, 0, 320, 159
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Log on to the Icarus Network"
FONT 8, "Tahoma"
BEGIN
EDITTEXT LOGONFORM_USERNAME,103,70,157,12,ES_AUTOHSCROLL
EDITTEXT LOGONFORM_PASSWORD,103,85,157,12,ES_PASSWORD |
ES_AUTOHSCROLL
PUSHBUTTON "Log on",LOGONFORM_LOGON,86,114,160,14
LTEXT "Forgot your password?",LOGONFORM_FORGOTPASSLINK,7,145,
75,8
LTEXT "Create a new Icarus Network account",
LOGONFORM_NEWACCLINK,190,145,125,8
LTEXT "Username:",IDC_STATIC,62,71,39,11
GROUPBOX "Enter your username and password to log on",IDC_STATIC,
51,56,218,48,BS_CENTER
LTEXT "Password:",IDC_STATIC,62,86,39,11
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
ICARUS_LOGONFORM, DIALOG
BEGIN
TOPMARGIN, 7
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
I'm using VC++ 6's resource editor. But I'm then loading the resources into VC++ 2005 BETA 2 and coding in there, if it helps you to know.
So, what's causing Tab and the X button to not work? I think it's to do with my CallBack function, but I'm new to Win32 so I couldn't really say.
Thanks in advance for any advice,
ukdeveloper.
[Edited by - ukdeveloper on July 27, 2005 10:32:53 AM]