Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why do common controls not work on my dialog box

Status
Not open for further replies.

aplumb

Programmer
May 28, 2001
2
AU
Can anyone help?

I am using Borland C++ 5.02 and creating a very simple app to display a dialog box. It works fine with a blank dialog box or if I have standard controls like edit boxes or push buttons.

However, when I include a progress bar, it builds fine, but will not run..... well, it does not create the dialog box.

=====================================================
Program code is listed here:
=====================================================

#include <windows.h>
#include &quot;res.h&quot;

/***************************************
Function Prototypes
***************************************/
BOOL WINAPI DlgProc (HWND hWnd, UINT msg,
UINT wParam, LONG lParam);
/***************************************
WinMain
***************************************/
#pragma argsused
int PASCAL WinMain(HANDLE hInstance,
HANDLE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
FARPROC fndlg = MakeProcInstance((FARPROC)DlgProc,
hInstance);
DialogBox (hInstance,
MAKEINTRESOURCE(IDD_DIALOG1),
NULL, fndlg);
return 0;
}

/************************************
Dialog Procedure for Main Dialog
***************************************/
#pragma argsused
BOOL WINAPI DlgProc (HWND hWnd, UINT msg,
UINT wParam, LONG lParam)
{
switch(msg)
{
case WM_INITDIALOG:
return(TRUE);

case WM_COMMAND:
switch (wParam)
{
case IDOK:
EndDialog(hWnd, FALSE);
break;

case IDCANCEL:
EndDialog(hWnd, TRUE);
break;
}
}
return(FALSE);
}

=====================================================
rc file listed below
=====================================================

/***********************************
testpgrs.rc
produced by Borland Resource Workshop
*****************************************/

#include &quot;res.h&quot;

IDD_DIALOG1 DIALOGEX 0, 0, 240, 120
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP
| WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION &quot;&quot;
FONT 8, &quot;MS Sans Serif&quot;
{
CONTROL &quot;OK&quot;, IDOK, &quot;BUTTON&quot;, BS_PUSHBUTTON |
BS_CENTER | WS_CHILD | WS_VISIBLE |
WS_TABSTOP, 186, 6, 50, 14
CONTROL &quot;Cancel&quot;, IDCANCEL, &quot;BUTTON&quot;, BS_PUSHBUTTON |
BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
186, 26, 50, 14
CONTROL &quot;Help&quot;, IDHELP, &quot;BUTTON&quot;, BS_PUSHBUTTON |
BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
186, 46, 50, 14
CONTROL &quot;ProgressBar1&quot;, IDC_PROGRESSBAR1,
&quot;msctls_progress32&quot;, WS_CHILD | WS_VISIBLE | WS_BORDER,
24, 78, 168, 13
}

======================================================
Information from target expert.
======================================================
The project target is an application (exe) for win32
platform. The target model is GUI, and I have included
the class libraries Framework and the linking is done
staticly.

======================================================
The program fails as it is at the moment, but if the
following section is removed from the rc file, it will
work. Can someone tell me why this is so ? The same
thing happens with other common controls from the resource
workshop toolbox.


CONTROL &quot;ProgressBar1&quot;, IDC_PROGRESSBAR1,
&quot;msctls_progress32&quot;, WS_CHILD | WS_VISIBLE | WS_BORDER,
24, 78, 168, 13
======================================================

 
You have to call the function InitCommonControls() before creating the dialog box ...
 
Thanks for the reply.....unfortunately I couldn't wait this long..... I posted this in May, and have since found out elsewhere what you have told me here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top