🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #4055

Month Calendar and Date Time Picker problem

#4055
From: Vladimir
Date: Tue, 16 Sep 2003 17:27
124 lines
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.
Technical Details
Message-ID: <1063733736.605766@ufacom.ru>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.sovam.com!sovam!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113dfb,f7f7a62f4f19e691,start
X-Google-Attributes: gid113dfb,public
X-Google-Thread: fcea4,f7f7a62f4f19e691,start
X-Google-Attributes: gidfcea4,public
X-Google-Thread: 108717,f7f7a62f4f19e691,start
X-Google-Attributes: gid108717,public
X-Google-ArrivalTime: 2003-09-16 10:50:03 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.sovam.com!sovam!not-for-mail
From: "Vladimir" <genisoft@ufacom.ru>
Newsgroups: be.comp.programming,comp.os.ms-windows.programmer.win32,comp.programming
Subject: Month Calendar and Date Time Picker problem
Date: Tue, 16 Sep 2003 23:27:58 +0600
Organization: Ufa GTS
Lines: 128
Message-ID: <1063733736.605766@ufacom.ru>
NNTP-Posting-Host: 195.239.153.9
X-Trace: news.rol.ru 1063733737 7598 195.239.153.9 (16 Sep 2003 17:35:37 GMT)
X-Complaints-To: abuse@online.ru
NNTP-Posting-Date: Tue, 16 Sep 2003 17:35:37 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Cache-Post-Path: ufacom.ru!unknown@195.218.142.61
X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)