|
Thank You Bob, This did solve my problem
However, now I am not getting output to my edit box. Here is what I am doing:
static CString mystring;
CProgressCtrl m_sigstr;
UINT getstring[4];
m_string.Format("%d",getstring[1]); // Format m_string with a decimal Number
static UpdateData(FALSE); // Send New string to Edit Box
m_sigstr.SetPos( getstring[1] ); // Set Position of Progress Bar according to getstring value
getstring [1] both holds the value I want to output to the edit box and use to reposition the progress bar. From a debug I did, it is not working on the progress bar as well as not outputting the value to the Edit Box.
|
|
|
|
|
CNewbie wrote:
m_string.Format("%d",getstring[1]);
static UpdateData(FALSE);
m_sigstr.SetPos( getstring[1] );
Consider that code fragment. I thought about the following things the moment I say it:
<list>What is that static word doing there?
Why do you call UpdateData(FALSE); in the middle of your updating process?
If you look up the UpdateData() function in MSDN, you see that this calls DoDataExchange() which synchronizes the data of all the controls on your dialog. Knowing this, you should move the call to UpdataData(FALSE) down the bottom of the function. After this, all the changes will be made visible.
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thanks for responding. I understand your logic, but the reason why I cannot do that is because that function loops over and over again every 500ms until a condition is met and then it exits. The Edit control as well as the progress bar will update at the bottom of every iteration. So you see if I put the UpdateData() at the end of the function, the edit box would never update until the function exited and that would defeat the whole purpose of what I want to do here.
|
|
|
|
|
Than put the call to UpdateData() after you update the progress bar instead of before it...
Sometimes, a little bit of experimenting will do magic for you...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Also If I dont put "static" in front of UpdateData(FALSE), I get this error:
error C2352: 'CWnd::UpdateData' : illegal call of non-static member function
|
|
|
|
|
I've never seen that before... It doesn't seem like legal C++ to me, but if the compiler accepts it, I must be wrong...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Are you attempting to update a control on the dialog from another thread? If so, this is extremely dangerous and not recommended.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thank you for the reply David. Do you have any recommendations on how I can go about outputting to the window from within this thread. Basically i want to do the math and output every 500ms.
Thanks
|
|
|
|
|
CNewbie wrote:
Do you have any recommendations on how I can go about outputting to the window from within this thread.
Yes, post a message back to the main thread who is in charge of the UI. See here and here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi
I have this supposedly simple problem.
I need my program to do some complicated calculations in response to some user interaction. While the thing is calculating, usually, it just sits there and doesn't take anymore inputs until it's done. This can take a few seconds. To remind the user that the program is thinking hard, I want to pop up a modeless dialog with messages like "obtaining parameters" and "performing a monstrous calculation".
So,
1) I popup a innocent looking dialog with a "create" and "show".
2) I set its title to whatever calculation it's supposed to be performing at the time.
3) I set the text of the edit box on this dialog to a more detailed description of what's happening inside the program as the calculation progress.
4) When the calculation is done, I put away the dialog.
All except number 3) (which is the important bit!) work. WHY??? I'm using a humble "SetWindowText" function which has worked fine a hundred times in the past! Any ideas what I might have missed? Or any ideas how I can look up this problem on the net?
Cheers
KK
|
|
|
|
|
After the SetWindowText call the UpdateWindow on the dialog..
SetWindowText will place a WM_PAINT in the queue, which is not being accessed due to your murderous calculation taking place in the same thread.
Hope this helps you...
Greets,
Davy
|
|
|
|
|
Wow, magic!
Thanks a lot!
|
|
|
|
|
Are you performing the "monstrous calculation" in a separate thread? If not, you should be. It's a much cleaner approach to what you are doing.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
No, I'm not using different threads. You are right, of course.
Just that, if you have a horse in the way, it might be wise to move it. But if you have an angry elephant in the way, I'd rather walk around it, even if I end up in the bushes...
The problem is, the calculation bits are so tangled up with loads of other stuff, it's a lot of hassle to move them just for the sake of a dialog box. I probably broke all the rules of good programming Getting it wrong now can only make my next project better
Thanks for the thought, anyway.
|
|
|
|
|
Kiriko wrote:
Just that, if you have a horse in the way, it might be wise to move it. But if you have an angry elephant in the way, I'd rather walk around it, even if I end up in the bushes...
Philosophy in a VC++ forum? Interesting...
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Given:
class C {
public:
void f() {};
};
void (C::*pmf)() = &C::f;
C* pC = new C;
pC->*pmf(); // OOps, Error
How to fix such problem? Thanks.
Andrew
|
|
|
|
|
try
(pC->*pmf)();
Greets,
Davy
|
|
|
|
|
|
Hello, I am using a CRichEdit control object and I am trying to insert a new character in the control, which I get from another window. The code looks something like this:
<br />
TCHAR str[4];<br />
GetDlgItem(IDC_MYWND)->GetWindowText(str, 4);<br />
m_richedText.ReplaceSel(str);<br />
The problem is that with some truetype fonts (e.g. wingdings) and certain character codes, especially above 128 but not always the character which gets pasted in the control is different (different code) than the one I got in the first place. The weirdest part is that if I replace the ReplaceSel() function with SetWindowText() , I get the correct character (but I can't use it, because I do not want to replace the whole text in the control).
I am going to try using the clipboard and CRichEdit::PasteSpecial() but, any ideas about why this is happening in the first place?
Thanks in advance.
Have no fear of perfection - You will never reach it
|
|
|
|
|
Another thing which I just discovered:
Say I had pasted some characters inside the rich edit control from a specific font (webdings in particular). The characters get pasted alright, but when I call SetDefaultCharFormat() or SetSelectionCharFormat() with this particular font face and charset=DEFAULT_CHARSET , some characters change, or disappear completely (change into control characters)!
Have no fear of perfection - You will never reach it
|
|
|
|
|
Salvador Dali wrote:
TCHAR str[4];
GetDlgItem(IDC_MYWND)->GetWindowText(str, 4);
This is incorrect as there is no room for the nul terminator. Either change the size of str to 5, or change GetWindowText() 's second parameter to to 3.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi Group
can anybody pls help me exactly how to determine the OS version remotely on a lan(in VC++).
Thanks in Advance.
Rgds
VC++
|
|
|
|
|
Use NetServerGetInfo() .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hello i don't want the server information,i just want to detect the os in all the computers present on the lan
|
|
|
|
|
In your original post, you indicated you wanted to "determine the OS version remotely." That is what NetServerGetInfo() does, among other things. Something like:
LPSERVER_INFO_101 pBuf = NULL;
NetServerGetInfo(pszServerName, 101, (LPBYTE *) &pBuf);
printf("%lu.%lu\n", pBuf->sv101_version_major , sv101_version_minor);
NetApiBufferFree(pBuf);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|