Solved

Dialog status bar from a .rc file

Posted on 2007-04-06
6
940 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

15 Experts available now in Live!

Get 1:1 Help Now