Jump to content
  • Advertisement
Sign in to follow this  
Portishead

[C++] Status bar doesn't get the text [New question inside]

This topic is 3403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to create a status bar, and set text to his first part, but it doesn't work. Here's the code I wrote:
HWND status_bar = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_CHILD | SBARS_SIZEGRIP,
 0, 0, 0, 0, hwnd, (HMENU)STATUS_BAR_ID, GetModuleHandle(NULL), NULL); 

int sb_parts[] = {100, -1};
SendMessage(status_bar, SB_SETPARTS, 2, (LPARAM)sb_parts);
SendMessage(status_bar, SB_SETTEXT, 1, (LPARAM)L"Ready...");



It does create the bar, but it doesn't seperate the parts and it doesn't set the text to the bar.. What could be the problem? Thanks for any helpers, Portishead. [Edited by - Portishead on April 22, 2009 2:55:33 PM]

Share this post


Link to post
Share on other sites
Advertisement
I think that should work...it's been a long time since I worked with the native API though. I'm looking at my old code and I always explicitly specified the widths of the parts, rather than using -1. Do you get anything different if you use something other than -1? Also just FYI, specifying 1 will set set the text of the second part since the index is 0-based for SB_SETTEXT.

Oh and just one more small FYI...you have WS_CHILD specified twice.

Share this post


Link to post
Share on other sites
I'm really an idiot.. I wrote WS_CHILD twice instead of WS_CHILD and WS_VISIBLE..
Thanks, that was the problem.

Another thing: I have an MDI application that you can open a new file (MDI child window) and open a file to be loaded into it(just for practice).
The problem is that I need to save the path that was loaded for each MDI, but I can't do it with one var.. I thought of doing a struct that contains information for each MDI, and save the structs in a list, but I'm not sure if that's the good way.. Is there a better way to do it?

Thanks for any helpers, again.

Share this post


Link to post
Share on other sites
You can keep the info with SetWindowLongPtr and GetWindowLongPtr with GWLP_USERDATA (it'd be a pointer to your structure with the necessary information). Generally you just pass 'this' to it...

Share this post


Link to post
Share on other sites
The problem is that I don't know if I already sent the struct with SetLongWindowPtr, and try to get it with GetLongWindowPtr, it throws an exception then.. Is there a way to know if data already been sent?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!