×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Why do common controls not work on my dialog box

Why do common controls not work on my dialog box

Why do common controls not work on my dialog box

(OP)
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 "res.h"

/***************************************
    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 "res.h"

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 ""
FONT 8, "MS Sans Serif"
{
 CONTROL "OK", IDOK, "BUTTON", BS_PUSHBUTTON |
   BS_CENTER | WS_CHILD | WS_VISIBLE |
   WS_TABSTOP, 186, 6, 50, 14
 CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON |
   BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
   186, 26, 50, 14
 CONTROL "Help", IDHELP, "BUTTON", BS_PUSHBUTTON |
   BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
   186, 46, 50, 14
 CONTROL "ProgressBar1", IDC_PROGRESSBAR1,
   "msctls_progress32", 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 "ProgressBar1", IDC_PROGRESSBAR1,
   "msctls_progress32", WS_CHILD | WS_VISIBLE | WS_BORDER,
   24, 78, 168, 13
======================================================

RE: Why do common controls not work on my dialog box

You have to call the function InitCommonControls() before creating the dialog box ...

RE: Why do common controls not work on my dialog box

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close