Solved

Dialog status bar from a .rc file

Posted on 2007-04-06
6
937 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

20 Experts available now in Live!

Get 1:1 Help Now