|
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
|
|
|
|
|
i want to add licensing in my software. how do i do?
|
|
|
|
|
Check here[^] and
here[^]
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
checked the article "Using XML Digital Signatures for Application Licensing"
but i need to integrate it with my VC++ code. how do i do?
|
|
|
|
|
Dear Mr. Loibl
I am from Indonesia would like to ask you about your program called GraphicSuite, I downloaded all but especially for the source files there is no .mdp file then I couldn't open "Workspace..." in Visual C++ editor.
Would you mind to give some comments for that reason?
Thank you.
PS : Would you mind to chat directly via E-Mail for more efficient than by discussion forum?
Name : Alvano Yulian
Office : National Nuclear Energy Agency
Centre for Nuclear Instr. Develoment
Address : PUSPIPTEK, Serpong
Tangerang 15310
INDONESIA
Phone : +62217560896
Fax : +62217560921
CellPhone : +628129958696
E-Mail : alvano_yulian@yahoo.com
|
|
|
|
|
why did you ask here, instead of the forum for the article ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a fairly complex application, to which I am adding socket communications for data logging. I have implemented an approach that uses a single winsock socket in a thread, and it's working ok. But it does not have the full functionality needed.
I designed the next implementation using CSocket and ran into a weird problem on actual coding. Even a simple declaration of a socket followed by a CSocket.Create(PORT, SOCK_STREAM) returns an error and fails. This is at initialization, where not much has yet happened.
It compiles fine under both VC++ 6SP5 and .net 2003. Doing this in a standalone application stump works ok, of course.
What could be going on here? I have been wasting more than half a day on this. Doing what I plan with winsock would take a lot more time.
Thanks for any hints,
-- Harald
|
|
|
|