📄 wpw_wapi_dialog_95.html
字号:
<HTML>
<HR><A NAME=WINAPI_DIALOG_MODELESS>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Modeless Dialog</H4><PRE>
(Newbie Question)
How do you get a MODELESS Dialog box to work.
Can anyone tell me what I'm doing wrong.
Code as follows:
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include "stcomms.hpp"
#include "commwin.hpp"
#include "res.h"
#define STCOMMSCLASSNAME (STCommsClassName)
#define STCOMMSWINDOWNAME (STCommsWndName)
#define STCOMMSMENUNAME "STCOMMSMENU"
#define STCOMMSDIALOGNAME "DIALOG1"
static char STCommsClassName[] = "STComms Class";
static char STCommsWndName[] = "Main Panel";
HWND hwndMain;
// Function Prototypes
int PASCAL WinMain( HINSTANCE, HINSTANCE , LPSTR , int);
long FAR PASCAL STCommsWndProc( HWND hWnd, unsigned msg, WPARAM
wParam, LPARAM lParam);
BOOL CALLBACK FTDlgProc(HWND , UINT, WPARAM, LPARAM);
int PASCAL WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR
lpCmdLine, int nCmdShow)
{
WNDCLASS wclass;
MSG msg;
if (!hPrevInst)
{
wclass.lpszClassName = STCOMMSCLASSNAME;
wclass.lpfnWndProc = STCommsWndProc;
wclass.style = CS_HREDRAW | CS_VREDRAW;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
wclass.hbrBackground = GetStockObject(LTGRAY_BRUSH);
wclass.hInstance = hInst;
wclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wclass.hIcon = NULL;
wclass.lpszMenuName = NULL;
if (!RegisterClass(&wclass))
return FALSE;
}
hwndMain = CreateWindow( STCOMMSCLASSNAME
, "Test Application"
, WS_OVERLAPPEDWINDOW
, 10
, 10
, 400
, 300
, HWND_DESKTOPP
, LoadMenu(hInst, STCOMMSMENUNAME)
, hInst
, NULL
);
if(!hwndMain)
{
return FALSE;
}
ShowWindow(hwndMain, nCmdShow);
UpdateWindow(hwndMain);
while (GetMessage(&msg, NULL, 0, 0xFFFF))
{
if(!IsDialogMessage(hwnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
DestroyWindow(hwndMain);
return msg.wParam;
}
//*****************************************************************************
// STCommsWndProc
//
// Main Window Procedure
//*****************************************************************************
long FAR PASCAL STCommsWndProc( HWND hwnd, unsigned msg, WPARAM
wParam, LPARAM lParam)
{
HINSTANCE hInst;
HWND hwndChild;
DLGPROC dlgproc;
switch (msg)
{
case WM_COMMAND:
switch(wParam)
{
case IDM_START:
dlgproc = MakeProcInstance((DLGPROC)FTDlgProc, hInst);
hwndChild = CreateDialog(hInst, STCOMMSDIALOGNAME,
hwnd, dlgproc);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0L;
}
BOOL CALLBACK FTDlgProc(HWND hwnd, unsigned msg, WPARAM wParam, LPARAM
lParam)
{
switch(msg)
{
case WM_INITDIALOG:
return TRUE;
default:
return DefDlgProc(hwnd, msg, wParam, lParam);
}
}
I've created a popup window called DIALOG1 (very original I know)
using my resource editor and its compiler into the EXE.
But I don't get anything on the screen.
Can anyone help?.
TIA
******************************
Dave
Dave@wilbert.demon.co.uk
******************************
<HR>
On 17 Jun 1995 21:23:48 +0100, Dave@wilbert.demon.co.uk (Dave Brown) said in article <3rvdkk$ivc@imp.demon.co.uk>:
>(Newbie Question)
>How do you get a MODELESS Dialog box to work.
>
>Can anyone tell me what I'm doing wrong.
>I've created a popup window called DIALOG1 (very original I know)
>using my resource editor and its compiler into the EXE.
>
>
>But I don't get anything on the screen.
I'd suggest checking the resource script for WS_VISIBLE is the dialog box
style flags.
--
Robert Mashlan R2M Software Company Programmer for Hire
mailto:rmashlan@r2m.com http://www.csn.net/~rmashlan PGP key available
Resources for Windows Developers - http://www.csn.net/~rmashlan/windev
Windows Developers FAQ - http://www.csn.net/~rmashlan/win-developer-FAQ
<HR>
>
>
>
Maybe this will help!
You are using the variable hInst in the CreateDialog function but you have not
assigned a value to it! The function will fail because the default value in
the variable is not valid.
</PRE>
<HR><A NAME=WINAPI_DIALOG_Disable_Control>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Disable Dialog Control</H4><PRE>
Robin Hilliard (robin@flapjack.ieunet.ie) wrote:
: Hi,
: I'm writing a simple dialog editor and need to display how dialogs will look
: in a running app. How do I create dialogs with controls which look 'live'
: but are not active? Using CreateWindow(), it's not a problem to get a real
: dialog box going, but I need the controls dead! Also, at some point in the
: remoter future, the program will have to support dragging of the controls
: about the dialog. [I'm using MFC2.5 under VC++1.51.]
Do "kill" your controls dead, use DISABLE flag or some analog. I'm using
BC 4.5, so I don't know how Microsoft is handling this, but in BC you can
overwrite SetupWindow() and there use controls own Disable() function.
Riho
</PRE>
<HR><A NAME=WINAPI_DIALOG_Update>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Update Dialog</H4><PRE>
: The dialog box shows up along with the gauge, but the gauge is not updated.
: i.e, it doesn't indicate that data is being read, although I know it is.
Try forcing the dialogbox to redraw himself. For example call Invalidate
after updating gauge.
Riho
<HR>
emd0748@umoncton.ca wrote something like
>The dialog box shows up along with the gauge, but the gauge is not updated.
>i.e, it doesn't indicate that data is being read, although I know it is.
>Have any ideas?
Several. Here some code from one of my projects. I believe your gauge doesn't
count because you didn't set the Range value (cf. prcssdlg.cpp below). I hope
you have no trouble doing the resource identifiers yourself ;-)
#if !defined(__prcssdlg_h) // Sentry, use file only if it's not already
included.
#define __prcssdlg_h
/* Project nce
The Programming with Puns Facility
No copyrights claimed
SUBSYSTEM: nce.apx Application
FILE: prcssdlg.h
AUTHOR: Alfons Hoogervorst
OVERVIEW
========
Class definition for TProcessDialog (TDialog).
*/
#include <owl\owlpch.h>
#pragma hdrstop
#include <owl\dialog.h>
#include <owl\gauge.h>
#include "nceapp.rh" // Definition of all resources.
//{{TDialog = TProcessDialog}}
class TProcessDialog : public TDialog {
TGauge* process;
int start, finish;
public:
TProcessDialog (TWindow* parent, TResId resId = IDD_PROCESS, int
startValue = 0, int endValue = 100, TModule* module = 0);
virtual ~TProcessDialog ();
void UpdateStatus (int newValue, BOOL doYield = TRUE);
void SetDescription (char* description = "");
//{{TProcessDialogVIRTUAL_BEGIN}}
public:
virtual void SetupWindow ();
//{{TProcessDialogVIRTUAL_END}}
}; //{{TProcessDialog}}
#endif // __prcssdlg_h sentry.
/* Project nce
The Programming with Puns Facility
No copyrights claimed.
SUBSYSTEM: nce.apx Application
FILE: prcssdlg.cpp
AUTHOR: Alfons Hoogervorst
OVERVIEW
========
Source file for implementation of TProcessDialog (TDialog).
*/
#include <owl\owlpch.h>
#pragma hdrstop
#include "prcssdlg.h"
//{{TProcessDialog Implementation}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -