Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

Progress Control addition to a Dialog Box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ziggy - 27 May 2005 18:07 GMT
Please excuse this elementary question...but I am just dumb....

I have taken a simplistic Dialog Box and added a Progress Control.
When I did that, my Dialog Box was no longer able to intialize using the
DialogBox macro.

If I remove the Progress Control from the form, the form displays
appropriately.  

Is there something that needs to be done in addition to providing a callback
function for the dialog?

Here is a brief outline of the code (which is quite simplistic).

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
    int wmId, wmEvent, rtn_val = 0;
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case IDM_ABOUT:
            rtn_val = (int)DialogBox(hInst, (LPCTSTR)IDD_FORMVIEW, hWnd,
(DLGPROC)Formview);

            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:

        hdc = BeginPaint(hWnd, &ps);
        // TODO: Add any drawing code here...
        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

// Message handler for progress bar form.
LRESULT CALLBACK Formview(HWND hDlg, UINT message, WPARAM wParam, LPARAM
lParam)
{
    switch (message)
    {
    case WM_INITDIALOG:
        return TRUE;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
        {
            EndDialog(hDlg, LOWORD(wParam));
            return TRUE;
        }
        break;
    }
    return FALSE;
}

The resource (IDD_FORMVIEW) is a simplistic dialog box with a couple of
Static Text fields and a "STOP" Button.

So I am stuck with the following:
1.) How can I get the form to display (i.e. should I ditch the DialogBox
macro?)
2.) How do I dynamically change the progress bar appearance (i.e. how do I
directly call into the form to change the appearance of  the bar)?

Any help or shove in the right direction would be appreciated.
ismailp - 27 May 2005 19:01 GMT
Nobody is dumb here!

1. Do following in your WinMain function:

int __stdcall WinMain()
{
               // ...
    INITCOMMONCONTROLSEX ics = {0};
    ics.dwICC = ICC_BAR_CLASSES;
    ics.dwSize = sizeof(INITCOMMONCONTROLSEX);
               // ...
}

Also, add
#include <CommCtrl.h>

to beginning of your source file, and link your application with
comctl32.lib

2. usually, another thread deals with the progress bar update and
dialog itself does not. check progress bar control reference for
further information about messages. but if you really want to learn how
bar works, insert a button into dialog and in your BN_CLICKED handler,
send a PBM_STEPIT or PBM_SETPOS message to progress bar control. in
your WM_INITDIALOG handler, set progress range with PBM_SETRANGE
message before using these messages. if you want to use PBM_STEPIT
message. also, if you consider using PBM_STEPIT, you need to use
PBM_SETSTEP message to set your stepping interval.

Ismail

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.