|
hi,
i have across a problem that is my program will warn me when executing for the code below
recv_server_thread=AfxBeginThread(recv_server, this);
UINT CTest2Dlg::recv_server(LPVOID param)
{
CTest2Dlg* pp=(CTest2Dlg*)param;
...
pp->m_string_peer="Number of Peers: "+Display_integer;
pp->UpdateData(FALSE);
the program can successfully be compiled,
but when it executes to that position,
it pops a windows "Microsoft Visual C++ Debug Library",
saying "Debug Assertion Failer!,
program: <my prgram..skip="">
File: wincore.cpp
Line: 895 ..."
but if i click skip,
the program can continue to run and update the string correctly.
SO is there any problem i have made?
AND using what program code instead of that I using can solve the problem?
Thank you very much~
|
|
|
|
|
drfankw wrote: AND using what program code instead of that I using can solve the problem?
The correct approach, IMHO, is posting a message to the main dialog, asking the latter to call UpdateData .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Short answer:
MFC does not work from multiple threads.
Longer:
The HWND -> CWnd mapping is on a per-thread basis, and you have to be VERY careful. I normally use class Win32 stuff in threads, and save MFC for the main thread only.
But you should be very careful when using multiple threads anyway.
Iain.
|
|
|
|
|
Dear all
the following is what i created 10 arrays, how to save these 10 arrays in a file using ofstream? i would like to name each array as 0,1,2,3,..9..late when i wanna use them, i can take it directly. another quession is why here setw(3) is not available? thanks.
#include <iostream>
using std::cout;
using std::endl;
#include <iomanip>
using std::ios;
using std::setw;
using std::fixed;
using std::showpoint;
using std::setprecision;
int main ()
{
double a[3][4];
for (int j = 0; j <10; j++)
{
double a[3][4] = {{(double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX,( double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX},{(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX,(double)rand()/RAND_MAX}};
cout<< setw(3)<< "Particle" << setw(3) << j << endl << endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 4; j++)
cout <<setw(3)<< setprecision(6) << fixed << showpoint << a[i][j] << " ";
cout << endl;
}
cout<< endl;
}
}
Li Zhiyuan
5/10/2006
|
|
|
|
|
What is your problem with ofstream ?
As a kick-off hint I suggest you to store your array element values in binary form.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
i would like to use each array of a[3][4] as named for example arry[10],if one condition is right, i will use arry[0]= a[3][4];if another condition is right, i use arry[1] = a[3][4],ihave 10 different arrays.. and so on....because i already got 10 3x4 arrays,....in previous ....
by the way, how to use ofstream to create 10 random arrays? thanks
Li Zhiyuan
5/10/2006
modified on Sunday, January 20, 2008 8:03:11 AM
|
|
|
|
|
li zhiyuan wrote: i would like to use each array of a[3][4] as named for example arry[10],if one condition is right, i will use arry[0]= a[3][4];if another condition is right, i use arry[1] = a[3][4],ihave 10 different arrays.. and so on....because i already got 10 3x4 arrays,....in previous ....
A bit confused. Please explain the requiremnt more clearly.
li zhiyuan wrote: by the way, how to use ofstream to create 10 random arrays? thanks
I guess do you mean serialization , i.e. that you need to store the array content to disk and, later, retrieve the values and build again the array. Aren't you able to perform such task? Why?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
yes, you are right, i just want to build 10 arrays using ofstream, in my whole program, i need to use it and one of friends suggested me i can create such 10 arrays and save them, late if i want to use, just open using ifstream.
which way is better, can you give me another way? how to create 10 3x4 random value arrays using ofstream? thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
li zhiyuan wrote: one of friends suggested me i can create such 10 arrays and save them, late if i want to use, just open using ifstream
Your friend was right. The above is the right way to go on.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
how to create 10 3x4 random value arrays using ofstream? thanks a lot.
Li Zhiyuan
5/10/2006
|
|
|
|
|
Well, roughly speaking, ofstream can store values on a file., it has nothing to do with array creation.
BTW you can
(1) create an array, assigning it random values.
(2) store it on file, using ofstream .
(3) later read file content (using ofstream ) to build a new array having the same content of the original one.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hello everyone,
How do you understand the Bjarne's comments about exception specification? Especially, "not required to be checked across compilation-unit" and "violations will not be caught at run time"?
section 14.6.1 Checking Exception Specifications
--------------------
Importantly, exception-specifications are not required to be checked exactly across compilation-unit boundaries. Naturally, an implementation could check. However, for many large and long-lived systems, it is important that the implementation does not -- or, if it does, than it carefully gives hard errors only where violations will not be caught at run time.
--------------------
thanks in advance,
George
|
|
|
|
|
I'm creating a casino slot machine game as a win32 application.
When clicking on an image - I catch such event by locating the mouse position in LBUTTONDOWN message I need to implement following behavior:
1 - I replace the image by another image (a black button image)
2 - from now on, some logic change so that a click on this image cant happen
3 - eventually, after some Sleep() button change back to normal, and can be clicked
my problem is - if you click on the button when it is black, the click happens. that is because an LBUTTONDOWN message created, and it waits in the message queue.
when 'synchronous' logic ends, the image can be clicked, so the message 'from the past' takes action.
two solutions:
1 - clear the message queue - haven't try that.
2 - send my own message at the end of stage 2 of function. that message will trigger stage 3. Any messages caught during stage 1-2 would take action before my custom message and it should act as desired.
BUT unfortunately, it looks like this message get before all the 'messages from the past'.
|
|
|
|
|
Hanan888 wrote: my problem is - if you click on the button when it is black, the click happens. that is because an LBUTTONDOWN message created, and it waits in the message queue
Why don't you use a flag (losely speaking, a global variable) marking the current button status as 'black' or not?
In the LBUTTONDOWN message handler then you can choose the proper action to do depending on that flag value.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
thanks but problem is different :
stage 1 of function -> 'button' becomes unclickable
{,,,,,,,,,,,,,,,,,,}
{,,,,,,,,,,,,,,,,,,} 'bad user' clicks on the black button - creates LBUTTONDOWN
{10 second duration} ('LBUTTONDOWN from the past')
{..................}
{..................}
need to trigger stage 2 of function -> becomes clickable
'LBUTTONDOWN from the past' create unwanted behavior
thats whay I tried to first do stage 1 - in the end business-logic 'flags' that button is unclickable
PostMessage(TRIGGER_STAGE_2....)
stage 2 happens
'LBUTTONDOWN from the past' happened between stage 1 and 2 so everything works right
but it seems like my TRIGGER_STAGE_2 push in the queue to be first (?!) so
'LBUTTONDOWN from the past' again happens in a bad time for me
|
|
|
|
|
The real question, IMHO, is: Why are you blocking the message queue for such a long time?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Thats a very good question which I actually didn't ask myself until now.
It looks like SetTimer() solved my problem, without blocking message queue.
thanks
|
|
|
|
|
I used postMessage(CUSTOM_MESSAGE,...)
my desired behaviour is that this message would get to the last spot in the message queue
but it seems that it get to the first spot
|
|
|
|
|
can anyone help me out how to create a wrapper for java in cpp ?
what i want to do is =>
1. suppose i have jar file...i have to extract it. (done)
2. find all its contents such as classes,methods using reflectin api's. (done)
3. invoke jvm. (done)
4. create a wrapper for methods ,class which are available from step 2 (in c++)(i dont know how to go about it.)
any kind of tips, sample code,source code of any already existing freeware s/w, links are most welcome... !
|
|
|
|
|
how do i load an ".sys" file in windows 98?
in windows XP, 2000, 2003 and Vista: i load it(.sys file) with calling OpenSCManager, CreateService, OpenService api functions, and i uninstall it with calling ControlService and DeleteService.
how do i load an ".sys" file in windows 98?
Zo.Naderi-Iran
|
|
|
|
|
I have a program. I want to distribute a passcode so that they
can register the software one-time. The way I currently handle this
is alot of work.
My thought process was this: to create a 100 passcodes like:
14123
45143
34533
just random numbers. I give a number to someone, they type in the
passcode and the software goes to a folder on the web, downloads
an ascii file, removes that number from the list of numbers on that
file, and then uploads that new file to the web. Since that number has
been removed, the passcode was only valid once.
I can download an ascii file from my website, but I can figure out
how to upload that new file to replace the existing file. My question
is twofold:
1. Is my strategy a good strategy for distributing passcodes? Anything
I can do to make it easier.
2. How can I upload a file to replace an existing file on the web?
Please, any response any one can give me will be greatly appreciated.
Sample projects are adored!!
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Here's how I do it. First of all, I use GUIDs for my passcode, to keep it unique and sufficiently long that it is unlikely to be guesed. Then, I get the processor Id and pass that through to a webservice, which checks if it's an Id already assigned to that passcode, or if that passcode has licenses available. Then it reports this to the client, where I store the passcode and a hashed response key in a file, so I can read that file and check it's validity for licensing in future.
The problem with your approach is that if someone reinstalls on the same machine, registration will fail.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Any chance you have a sample project or know of a sample
project that does something like this?
Please let me know.
My email address is brinasas@yahoo.com
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Hello!
Is there any way to get a notification when Windows enters the hibernate state? Is a windows message sent, or can one register a callback?
I've found the WM_POWERBROADCAST message, however it seems that you can only detect the standby modus with it, not hibernation.
Best regards
Dominik
|
|
|
|
|
The PBT_APMSUSPEND event (in a WM_POWERBROADCAST message) doesn't indicate
the system is entering hibernate state?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|