Thread View: be.comp.programming
2 messages
2 total messages
Started by Vladimir
Tue, 16 Sep 2003 17:27
Month Calendar and Date Time Picker problem
Author: Vladimir
Date: Tue, 16 Sep 2003 17:27
Date: Tue, 16 Sep 2003 17:27
124 lines
4300 bytes
4300 bytes
Hello,
I've wriiten an application in pure Win32 API. Code is below. It must show
simple dialog screen with subj. But it doesn't. Macro DialogBox returns soon
after I call it with nRet = -1. When I remove subj controls from dialog,
everything works fine. What is the problem?
// mfcsvr.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
HWND g_hWnd;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK CALLBACK FormProc(
HWND hDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam) // second message parameter
{
switch(uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if(LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
SYSTEMTIME st;
MonthCal_GetToday(GetDlgItem(hDlg, IDC_MC1), &st);
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
// register window class
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = 0;
wc.lpszMenuName = NULL;
wc.lpszClassName = "mfcsvr";
RegisterClass(&wc);
g_hWnd = CreateWindow("mfcsvr", "mfcsvr", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
hInstance, NULL);
if(!g_hWnd)
return 0;
long nRet = DialogBox(hInstance, MAKEINTRESOURCE(IDD_FORM), g_hWnd,
(DLGPROC)FormProc);
if(nRet == IDCANCEL)
return 0;
// Main message loop:
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
exit:;
return 0;
}
////////////////////////////////////////////////////////////////////////////
/
//
// Dialog
//
IDD_FORM DIALOG DISCARDABLE 0, 0, 228, 124
STYLE DS_MODALFRAME | WS_CHILD | WS_CAPTION
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_EDIT1,80,7,50,14,ES_AUTOHSCROLL
COMBOBOX IDC_COMBO1,140,7,80,70,CBS_DROPDOWN | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
CONTROL "MonthCalendar1",IDC_MC1,"SysMonthCal32",MCS_NOTODAY |
WS_TABSTOP,7,27,123,90
CONTROL "DateTimePicker1",IDC_DTP1,"SysDateTimePick32",
DTS_RIGHTALIGN | DTS_UPDOWN | DTS_APPCANPARSE |
WS_TABSTOP | 0x8,140,27,80,15
DEFPUSHBUTTON "OK",IDOK,140,47,81,30
PUSHBUTTON "Cancel",IDCANCEL,140,87,81,30
LTEXT "Search Mask",IDC_STATIC,7,7,63,15,SS_CENTERIMAGE
END
Regards,
Vladimir.
Re: Month Calendar and Date Time Picker problem
Author: Elias Fotinis
Date: Wed, 17 Sep 2003 20:49
Date: Wed, 17 Sep 2003 20:49
8 lines
2021 bytes
2021 bytes
Vladimir wrote: > I've wriiten an application in pure Win32 API. Code is below. It must > show simple dialog screen with subj. But it doesn't. Macro DialogBox > returns soon after I call it with nRet = -1. When I remove subj > controls from dialog, everything works fine. What is the problem? Use InitCommonControlsEx at the beginning of WinMain, to make sure the mentioned control classes get registered, before you try to use them.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads