|
I want to display value of one var in a progress to status bar immediatly by SendMesage(). How to di this ?
Please help me,
thank.
|
|
|
|
|
What you should do is run your process in another thread, otherwise your core problem is that your status bar won't update itself until your other task finishes.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I would assume you are using MFC.
If you are doing the processing inside CMainFrame, then you could simply use:
m_wndStatusBar.SetPaneText(Pane_No, "New Text");
If you are using the View, then use a user-defined message to send to CMainFrame. You can use resource.h and define your message id:
#define WM_MY_SETTEXT 3020
And include resource.h in mainframe.
From the View, send the message away:
AfxGetApp()->GetMainWnd()->SendMessage(WM_MY_SETTEXT,0,(LPARAM)"Hello old man");
In mainframe.h, declare your own message handler:
LRESULT OnMyMessage(WPARAM, LPARAM);
In mainframe.cpp, include your function in the message-map macro:
...<br />
ON_MESSAGE(WM_MY_SETTEXT,OnMyMessage)<br />
END_MESSAGE_MAP()
Then later in mainframe.cpp, implement it:
LRESULT CMainFrame::OnMyMessage(WPARAM, LPARAM lParam)<br />
{<br />
TCHAR* pS = (TCHAR*)lParam;<br />
TCHAR ss[200];<br />
strcpy(ss,pS);<br />
m_wndStatusBar.SetPaneText(0,ss);<br />
return 0;<br />
}
this is this.
|
|
|
|
|
CStatusBar class has a method called SetPaneText(). You can use that.
For eg:
CStatusBar s;//Your status bar
s.SetPaneText(nIndex, "Caption", TRUE);
This is another option.
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Anyone able to get boost compiled with VC8? If so...what did you do, how ...etc?
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
I've torn out what little hair I have on this.
I'm using VS 2005 Beta in case it makes a difference.
I create a new Dialog-based MFC App.
I put a picture control on it (CStatic with frame style).
I align a couple of scrollbars to the frame edge.
(I gave up trying to get the inherent CWnd scrollbars to work, but they behave the same.)
I try to code behind the scrollbars with calls to:
- SetScrollInfo()
- EnableScrollBar()
- ShowScrollBar()
( slightly different functions are required for the CWnd scrollbars)
The effects of SetScrollInfo() can be seen in the thumb size, and the ShowScrollBar() works as expected. But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce?
I can't see the magic secret in any projects I've downloaded. Help!
|
|
|
|
|
What's more, in the resources, the scrollbars show in a nice Windows XP style. When the app runs, they are flat and ugly. Hmmm. If there is someone out there that can take 5 mins to do this in both VS 2005 Beta and VS 2003, and find that I'm beating my head against a bug in VS 2005 Beta, that would at least be partial relief!
|
|
|
|
|
Jamaica wrote: But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce?
The image is most certainly not going to move by itself, you need to write your OnPaint handler to show the image based on the scroll position, then call Invalidate() when a scroll event fires. You say you've got one, there's obviously a problem with it being hooked up at this point in time, if it's not fired.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What you say is all true... but has not advanced my cause
There certainly is a hidden problem here. I've read the entire CScrollBar documentation several times, satisfied myself (e.g. by calling SetScrollPos()) that the scrollbar is just itching to be useful to me. The main problem appears to be getting any messages to or from it. There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves. I get the sense I'm going to shoot myself when I discover how simple the answer is....
|
|
|
|
|
Jamaica wrote: What you say is all true... but has not advanced my cause
*grin* I'm sorry, without looking at the code, that's about all could offer.
Jamaica wrote: There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves.
I have vs2005 final, and I created an MFC app, added a scroll bar and a message handler, and it fired fine. Why don't you create a new app that just does those things and see if it works ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is it just me, or do you consider code like the following to be somewhat overkill or wasteful for testing for an empty string...
if( 0 == stricmp(szString, "") ){
or
if( 0 == strlen(szString) ){
when I think it is sufficient to merely do this:
if( !szString[0] ){
What are some of your opinions on this matter?
|
|
|
|
|
I usually do the second one (strlen). To me it is more obvious that I am checking to see if the length of the string is zero. The last method will save you a couple CPU cycles, but it is not as obvious what you are doing IMO.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks for your reply.
I agree, the strlen could be a performance hit, but more understandable.
|
|
|
|
|
even if the 3 ones give the same result, it depends if lisibility is more important than performance...
i prefer using strlen() == 0 because the one who read back my code directly understand what i do there...
anyway, PJ Arends' answer is very good too
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 4:24 Tuesday 22nd November, 2005
|
|
|
|
|
Blake Miller wrote: if( !szString[0] )
This one's better if and only if you wrap it inside a function called
BOOL IsEmpty(char *str)
{
return !str[0];
}
Hey the function name can change
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I would just cut the string into 1 foot sements so I can easily see both ends. If there is nothing on either end, and no clothespins are clipped in the middle it's an empty see style string.
Walter J. Boncal
|
|
|
|
|
Hey,
how can I manage to print the content of a CRichEditCtrl or a CString containing a rtf-text to an pDC (screen or printer).
Thank you for helping me...
|
|
|
|
|
pDC->DrawText will simply paint normal text on the screen but since you are using rtf-text which means that there can be a lot of things in it, therefore, you have to parse the text first somehow and then paint the things one-by-one. I am sure there will be some libraries which do this. Search here on codeproject.
Regards,
Aamir
|
|
|
|
|
Hello,
I have a dialog app with a menu that allows the user to bring up different windows as they wish. I remember seeing a tutorial/article that had an easy way of placing a check mark next to the menu option that was already selected. (Essentially having the window being displayed already)
Can someone point me to this article.
Currently I am using this code that I had copied way back when(It dies on the first line, even though it works on my older app):
void CMyDialog::CheckMenu(int checked) <br />
{<br />
CMenu* pMainMenu = GetParent()->GetMenu();<br />
<br />
CMenu* pSubmenu = pMainMenu->GetSubMenu(2);<br />
<br />
UINT g = pSubmenu->GetMenuItemID(1); <br />
<br />
CString mnustr;<br />
<br />
pSubmenu->GetMenuString(1, mnustr, MF_BYPOSITION); <br />
<br />
<br />
if (checked) <br />
pSubmenu->ModifyMenu(1, MF_BYPOSITION | MF_STRING | MF_CHECKED, g, mnustr);<br />
else <br />
pSubmenu->ModifyMenu(1, MF_BYPOSITION | MF_STRING | MF_DISABLED, g, mnustr);<br />
}
Thanks!
-- modified at 15:06 Monday 21st November, 2005
|
|
|
|
|
NYTSX wrote: CMenu* pMainMenu = GetParent()->GetMenu();
What does GetParent returns ?
is your application a normal MDI/SDI application ? or is it dialog based ?
If it's the former, you will need to add a handler for the ON_UPDATE_COMMAND_UI and do something like
void CMainFrame::OnMyHandle( CCmdUI* pCmdUI )
{
pCmdUI->SetCheck( checked );
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
GetParent throws the error "unhandle exception. Access violation"
This is a dialog based app. The code that I am currently using is from a MDI app that I just called the method with no problems.
Thanks for your help
-- modified at 15:31 Monday 21st November, 2005
|
|
|
|
|
Can anyone help with this? The code I got this from was from a MDI app....but I don't know the changes I need to make to get it to work in a dialog app.
I think the problem is that I am having a problem getting the handle to the menu itself.
The scenario is that I have a main dialog who owns the menu (or so I think) which in turn will instantiate another dialog.
Thanks for your help.
|
|
|
|
|
Hello,
I've got a little problem when I want to debug my DLL. The situation is as follows:
- I've a DLL project and I've buildt a debug version of the DLL with the
PDB file.
- I've another project and I want to test the DLL by calling it's functions
with predefined data. When I hit a application breakpoint, I want to step
into the DLL's code.
- The DLL and the PDB are in the same folder as the test application.
The problem is that VS2005 says that no debug symbols are loaded for the DLL. Is there a way to load those symbols manually, or am I doing something wrong?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I have not done any DLL debugging with VS2005 yet, however in the past to get a DLL to step debug I had to start the debugger from the DLL project specifying the EXE that will load the DLL. If you cannot get the EXE to stop at the point you wish, just put an "_asm int 3h" inline and the debugger will stop. If its a debug build it should automatically pull in the source.
|
|
|
|
|
Hello,
Thanks for your reply. I think that MS changed the way the DLL's are debugged. I can't get the source, even with the __asm int 3 jump in the debugger hack...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|