|
Hi all,
I need to update the statusbar text of an SDI app. from within multiple views created using a splitter. How do I do this? The statusbar is instantiated in the mainframe (CMainFrame), and I don't appear to be able to access it. It would be nice to create a document level function that could set the statusbar text so that from each of my views I could do something like GetDocument().SetStatusBarText("Hello");
Any ideas??
TIA
Jonathan Thorpe
|
|
|
|
|
CStatusBar* CMainFrame::GetStatusBar()
{
return &m_wndStatusBar;
} Now you have access to it. CMainFrame is accessible anywhere; call AfxGetMainWnd() and cast the return to a CMainFrame*
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
I have a class that docks resizable dialogbars,.. but I have a problem saving the state and loading it. The states are actually save/load correctly but because my dialogbars are dynamic, by this I mean that if I start the application then there might only be 3 dialogbars and next time prehaps only 10 or 1 or whatever...
The LoadBarState crashes when I do this,.. does anybody know that MFC internal code does to save the dialogbar states,.. prehaps saving and loading it myself might work better... but I can't see what the internal values are?
anybody.
Peter Marino ( IO Interactive )
|
|
|
|
|
The way I got around this was to create the dialogbars myself (using new) BEFORE calling LoadBarState. That way, you don't rely on the framework to create them for you. This assumes, though, that the dialogbars you want to open on launch of your app are the ones that were open when you last shut it down.
Let me know if you need any more help.
|
|
|
|
|
That's my main problem,.. all my dialogbars are created via plugins,.. and I can't assume that all users will have the same number or even the same plugins when they start the application. So I need a general way of positioning the dialogbars on startup.
For example if a user has dialog A,B,C. And next time he starts he has dialogbar A and D. Then dialogbar A should have the same position as last time, and because dialog D is new it should be set to floating. The main problem is that LoadBarState is expecting the same number of dialogs and that the dialogbars have the same ID. Because the plugins are dynamic then all dialogbars are given different ID numbers at startup.
I hope this makes it clearer.,
Peter Marino ( IO Interactive )
|
|
|
|
|
Damnit! I just typed out this whole response to you, and Explorer ate it. Frigging microsoft...
Anyways, here's the gist of what i typed:
I can tell that my app will be heading down this exact same path, so I hope we find an answer to this question together.
I think that Load/SaveBarState info is all contextual info, meaning, the info is based on the dialogbars docked position/size relative to (in the context of) all the other docked dialogbars and toolbars, so I don't think LoadBarState will ever be able to work for you under these circumstances.
Even if you get around that, you'll still have to figure out a way to get LoadBarState to ignore (i.e. not create) dialog bars for which the user doesn't have a dll for.
There is a method on CFrameWnd called GetDockState which fills a CDockState object. You might try calling that to see what you can find.
But, I think your best bet is to do the loading/saving of docking info yourself, and use a couple of undocumented public methods on CControlBar:
void GetBarInfo(CControlBarInfo* pInfo);
void SetBarInfo(CControlBarInfo* pInfo, CFrameWnd* pFrameWnd);
browse the MFC source code to see how these work. They are declared in the header AFXEXT.H, and CControlBarInfo is defined in AFXPRIV.H, as are a couple of other useful classes.
Let me know what you find!
D
|
|
|
|
|
p.s. This comment is at the top of those header files. So, use at your own discretion/caution:
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
|
|
|
|
|
oops. meant to copy this in:
// Note: This header file contains useful classes that are documented only
// in the MFC Technical Notes. These classes may change from version to
// version, so be prepared to change your code accordingly if you utilize
// this header. In the future, commonly used portions of this header
// may be moved and officially documented.
|
|
|
|
|
ok,.. I've worked a couple hours on this,.. and I have a version now that can save some of the dialogbar states and reload them dynamically. This works also if the ID has changed and if the dialogbar is new or delete... so far so good....
now I have problem with that if two dialogbars share the same row,.. they do not get put into the same row,.. do you know what information that tells CControlBar what row/column a dialogbar is in?
Peter Marino ( IO Interactive www.marino.dk )
|
|
|
|
|
I'm not exactly sure. There is a class derived from CControlBar called CDockBar, which is does the docking for controlbars. You might look at CFrameWnd::DockControlBar source, and CDockBar::DockControlBar source, and the MSDN docs on them, and see what you can do. I think all you need to do is supply a rectangle in screen coordinates to CDockBar::DockControlBar, but I haven't looked into it enough...
Lemme know, and good luck.
|
|
|
|
|
The CDockBar is not documented,.. and I only have the header source,...
do you know where I could get some information on it? and where I could get the .cpp source for it?
|
|
|
|
|
It's not documented because it's likely that the methods and variables of the class will change in future releases. If you go to your VC installation Directory:
...\Microsoft Visual Studio\VC98\MFC\SRC
and do a search for files below that directory with the text "CDockBar::" in them. You should get
BarDock.cpp and DockStat.cpp. CDockBar implementation is in BarDock.cpp, but look in both for useful info.
|
|
|
|
|
|
I've done some debugging,.. checking to see how the CControlBar is intergrated with MFC... I would really like to say thanks for pointing out that the source code for MFC was on my harddisk I didn't even know that.
I haven't any solution right now,.. and I have just started my vacation and will be leaving tommorow to see the WM for Tumbling/Trampolin the next 1½ weeks,... so there will be a pause before I can continue,... but as soon as I get back,.. I'll continue where I left off and notify you of my status.
thanx again
Peter Marino ( IO Interactive )
|
|
|
|
|
If I want to use in exa numbers (base 16)
Which is type of variable I need ? (int, double,BYTE or another) ?
|
|
|
|
|
Hexadecimal (base 16), commonly called hex (not exa), is a way to _represent_ numbers, not a way to store them. You can use any integer variable size you want - bytes, words, double words, etc. I suppose there is some use for hexadecimal floating-poi8nt values, but I can't imagine what it would be.
If you want to get hex representations of these numbers as strings, use the various forms of printf(). To get integer values from hex strings, use the strtoul() function.
Good luck.
|
|
|
|
|
|
I'm desesperated. I wanna make the scroll lock light blink.
I had these functions:
BOOL GetLight()
{
return (1&GetKeyState(VK_SCROLL)); //I tried GetAsyncKeyState and nothing
}
void SetLight(BOOL bState)
{
if(bState)
{
if(GetLight()) //Already on
return;
//Simulate the keystroke
keybd_event(VK_SCROLL, 0, KEYEVENTF_EXTENDEDKEY,0);
keybd_event(VK_SCROLL, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);
return;
}
if(!GetLight()) //Already off
{
return;
}
//Simulate the keystroke
keybd_event(VK_SCROLL, 0, KEYEVENTF_EXTENDEDKEY,0);
keybd_event(VK_SCROLL, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);
return;
}
OnTimer(UINT nIDEvent)
{
if(nIDEvent==ID_TIMER_BLINK)
{
if(BLINK)
{
SetLight(TRUE);
BLINK=FALSE;
}
else
{
SetLight(FALSE);
BLINK=TRUE;
}
}
}
I know the logic of the functions can be improved (ands, ors and whatever). Well, those functions work fine if you don't start threads in Windows 9x (in Windows 2000 the functions work fine with threads).
If I start threads in Windows 9x the blink period is perturbated and the GetLight function doesnt work correctly. I tried to use the AttachThreadInput function and nothing, the GetAsyncKeyState and nothing, Sleep times between keybd_event and nothing, what can i do???.
Please help me, I'm desperated.
Thanks in advance.
:confused:
|
|
|
|
|
As an aside to my last post I have a related question. If I wanted to populate a linked list in a function called foo would I be best to do this:
--
std::list<cperson> MyList;
obj.foo( & MyList );
--
(ie instantiate it on this side and pass a reference to the place where it gets filled.)
Or secondly, I ould do it like this:
--
std::list<int>* MyList = obj.foo;
std::list<int>* obj::foo() {
// fill list
return &list;
}
--
Now, the second one feels better, but there is an issue in that if I dont create the list inside foo on the heap then it will get deleted when foo finishes. But If I create it using new then does the returned pointer have the right to use delete etc as it doesnt "own" the object.
Thanks
|
|
|
|
|
Could some people give me some clues as to how you come up with classes etc in your programs??
I often have problems like this one Im having now - I want to change the status bar text from somewhere in my program (I think its the view class), but to do so I need to get at the m_wndStatusBar object which is instantiated in the main frame class. How can I possibly do something like this?? A lot of the time it would make sense to write an member function and call this from the view, but as I dont have anything a CMainFrame instantited in the view then obviously in this situation this would be no use.
Another problem I also have often is this. If for instance I am designing a Contact Management system. I might have two extra classes - a CContact and a CDatabase (to encapsulate the database stuff.) I have a button in a Dialog, (or a menu handler in the view) which is supposed to fill a linked list with CContact objects then what am I best to do. As I see it there are a few ways:
1. Instantiate CPerson objects in the dialog and pass them to the database class to fill?
2. Instantiate a CDatabase object in the CContact class and make this class call methods of the database transparently - so I can do MyPerson.GetPersonDetails() and the database stuff is transparent.
There are probably many more ways to approach the above problem too. But hopefully I made clear the problems I am having- basically decididng on which classes to use, deciding which classes should contain instances of other classes, and then when I have implemented this, what is the course of action if I need some info from a class which I dont have access to.
Any help on this subject would be . appreciated, and Im sure lots of other people must have the same kind of confusion on this topic too...
Thanks,
Ben
|
|
|
|
|
Hi,
I have a HBITMAP and want to get a Bitmapinfoheader structure from it, wo i can access the width and height members.
Anyone offer me any advice.
Cheers
Richard
|
|
|
|
|
to get a DIB from an HBITMAP you use GetDIBits. (a DIB is a BITMAPINFOHEADER followed by an image).
but if you just want the width and height, use GetObject.
[code]
BITMAP bmp;
GetObject(hBmp, sizeof(BITMAP), &bmp);
width = bmp.bmWidth; // etc.
[/code]
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Sorry, I am a new boy to this, may anyone of u tell me the answer, please, urgent! Many thanks!
Reguards,
will
|
|
|
|
|
here is what I got
treeDialob dlg;
dlg.m_edit.
//is there something I can put here to make it //disappear?
dlg.DoModal();
Thanks a lot!!
|
|
|
|
|
Hi,
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT1);
pEdit->ShowWindow(SW_HIDE);
// pEdit->EnableWindow(FALSE);
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|