Solved

Dialog status bar from a .rc file

Posted on 2007-04-06
6
943 Views
Last Modified: 2013-11-20
First of all I am using the API not MFC, but since there is no API section, my question goes here.

I want to create a status bar on a dialog window. If I do:

CreateWindowEx(0, "msctls_statusbar32", NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd_main, NULL, GetModuleHandle(NULL), NULL);

It works fine. But I want to create it in the resource file (.rc). I try (inside the DIALOG definition):

CONTROL "", IDC_STATUSBAR, "msctls_statusbar32", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0

It compiles fine but no status bar appear. Any Ideas?
0
Comment
Question by:acerola
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:Priyesh
ID: 18870206
Try this -
    CONTROL         "",IDC_STATUSBAR,"msctls_statusbar32",CCS_BOTTOM,11,52,147,30

0
 
LVL 1

Author Comment

by:acerola
ID: 18870259
Same thing. It compiles ok, but no status bar appear on the window.
0
 
LVL 9

Expert Comment

by:Priyesh
ID: 18870311
Have you done the InitCommonControlsEx call in your app's WinMain ?
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 1

Author Comment

by:acerola
ID: 18870347
I found the problem: when I call SetMenu, it pushes all controls down to insert the menu, and the status bar is pushed outside the dialog. If I take out the SetMenu, the status bar appears fine. When I create the status bar using CreateWindowEx, the status bar is created after the menu is inserted, so the problem doesn't happen.

This is the cause of the problem, but I still have no solution.
0
 
LVL 9

Accepted Solution

by:
Priyesh earned 50 total points
ID: 18870462
I am trying this in Visual C++ 6.0, SDK app. Works fine for me even after i added the menu. What version of visual studio are you trying this in?

Here is my dialog resource -

IDD_ABOUTBOX DIALOG DISCARDABLE  22, 17, 230, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "About"
MENU IDC_SDKTEST
FONT 8, "System"
BEGIN
    ICON            IDI_SDKTEST,IDC_MYICON,14,9,20,20
    LTEXT           "SDKTest Version 1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX
    LTEXT           "Copyright (C) 2007",IDC_STATIC,49,20,119,8
    DEFPUSHBUTTON   "OK",IDOK,195,6,30,11,WS_GROUP
    CONTROL         "",IDC_STATUSBAR,"msctls_statusbar32",0x3,0,59,230,16
END
0
 
LVL 1

Author Comment

by:acerola
ID: 18870488
MENU IDC_SDKTEST

Yes, that works. I was doing:

SetMenu(hwnd_main, LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MAINMENU)));

And SetMenu would push the status bar outside.

Thanks for the help.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 181
tripleUp challenge 7 78
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 119
mapBully challenge 6 127
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now