|
Argh! Of course. I should have remembered that! Thanks for the explanation
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Not a problem.
One of my pet peeves is that all these fancy new libraries (MCF, .NET) make it easier to
get started, but can abstract you so far from the underlying OS that is easy to forget
what is *actually* going on.
I'm from the old school a little bit. I like to be able to use the bottom layer before
I then "forget" it and move on to the fluffy easy-making higher layers.
Eeeeh, when I were a lad, we only had 3 8 bit registers, push, pop and we liked it!
Iain.
|
|
|
|
|
Iain Clarke wrote:
Eeeeh, when I were a lad, we only had 3 8 bit registers, push, pop and we liked it!
I still do - I do a lot of embedded programming and love it!!
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
so does it mean that every control that runs under console app should have atleast a message pump if not the queue.
|
|
|
|
|
I don't know what you mean by "console control", but I presume you mean
an console application.
A message pump is just a fancy name for a loop like the following
while (GetMessage (...)) // Possible using PeekMessage to be more complex
{
if (ShouldWeQuitThisLoop (...))
break;
ProcessTheMessage (...);
DispatchMessage (&msg);
}
This loop (or something very similar) is at the heart of window apps
WinMain ( its in CWinApp::Run () as I remember), DialogBox function,
etc.
So its written for you by microsoft if you just call (e.g) MessageBox.
As I remember, these functions are in USER.DLL. Also there is the message
queue. So using a function that would need a message loop also links in
the queue. Neat, eh?
Essentially, you can all but forget about this, but keep it way back in
your mind for wierd behaviour explanations.
Iain.
|
|
|
|
|
Even though I didn't post the question, thank you for that answer. It all makes sense now.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
I am using crystal report 8.05 to desigen the report.
Report is connected to user DSN . Database used is MYSQL 3.51.
The report is displyed by application developed in VC++.
When I open the report I get the error ' can not open SQL server'. Solution to this problem is to download P2sodbc8.zip file and load P2sodbc8.dll .
I tried it out but still getting the same problem
|
|
|
|
|
Hi !
I want to write a macro which will be used each time an error is found in my source code. This macro will display a text and I want it to display the line in the source code where it is called.
Is it possible to do that ? Is there a way to get the actual line of the source code ?
Thank you for your help,
Jerome
|
|
|
|
|
The __LINE__ is defined as the current line of the source file. It is treated exactly as a string literal, so you can do what you like with it except modify it, of course
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
At one place
long m_lReturnID;
m_lReturnID=MessageBoxEx(m_hptr,//The HWND handle to the parent dialog
"Hello, are you ok?",
"Ok?",
MB_YESNO|MB_ICONQUESTION|MB_TOPMOST,
LANG_ENGLISH);
______________________________________
At another place
I want to shut up the dialog if the dialog is still on
How to solve this?
Please help me!
Thank you in advance!
|
|
|
|
|
You can't using MessageBoxEx() . You'd have to write your own dialog class, and send it some sort of message from another thread.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Actually, you could simulate a mouse click on the message box to click one of the buttons...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I want to do like this
But I don't know how to simulate a click on the button.
Can you tell me how to finish this function?
|
|
|
|
|
There are two ways:
1. Get the location of one of the buttons (use GetWindowRect() ) and send a WM_LBUTTONDOWN message.
2. Send a WM_COMMAND /BN_CLICKED message to the dialog, with the IDOK identifier.
I would probably do the second one. Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I do like below:
PostMessage(WM_COMMAND,IDYES);
SendMessage(WM_COMMAND,IDYES);
But neither of them can shut up the dialog.
what's wrong with me?
|
|
|
|
|
Are you sending it to the correct window?
You have to do:
PostMessage(WM_COMMAND, MAKEWPARAM(BN_CLICKED, IDYES), (LPARAM)hwndYesButton); after getting the window handle to the yes button.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Oh
I call the function after I click a button on my main dialog.
Can that work?
In addition
"hwndYesButton" is an undeclared identifier in my project.
|
|
|
|
|
Aleon666 wrote:
"hwndYesButton" is an undeclared identifier in my project.
Of course that would not exist in your project.
That's the handle of the "Yes" button in your dialog, or maybe the "OK" button. You have to define in and then the value can be obtained by calling GetDlgItem( HWND hDlg, int nIDDlgItem ) or the CWnd::GetDlgItem( UINT nID ). Then you should call the function that Ryan told you earlier:
PostMessage(WM_COMMAND, MAKEWPARAM(BN_CLICKED, IDYES), (LPARAM)hwndYesButton);
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
You will have to call the function from a different thread, but it should work. You won't be able to use the MFC window pointer. You'll need to use the m_hWnd member of the CWnd pointer. But yes, it should work after clicking on a button from your dialog.
You will need to declare hwndYesButton as an HWND and get the window handle of the yes button (not an easy task. I'm not sure exactly how to do it).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
(not an easy task. I'm not sure exactly how to do it)
Do you think that sending a WM_CLOSE message to the dialog would take of everything? I have done it with a Splash window that I designed once and yes I used a thread for it.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Toni78 wrote:
Do you think that sending a WM_CLOSE message to the dialog would take of everything?
Hmmm, maybe. Remember that the MessageBox() function returns a value depending on which button was pressed. What does it return in it gets a WM_CLOSE . His code will have to make sure that it does the right thing...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
What does it return in it gets a WM_CLOSE.
It always returns zero (if the window processes the message). I think Aleon just wants to close the dialog. But if it is a modal dialog box then EndDialog can be used and the result can be passed as a parameter. If not then your answer still remains the best solution (in my opinion).
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Aleon666 wrote:
But neither of them can shut up the dialog.
what's wrong with me?
Simply tell the dialog to shut up and I don't know what could be wrong with you. What kind of symptoms are you experiencing? Just joking.
Seriously, Ryan's last post gives you the correct answer. Where exactly are you calling PostMessage and SendMessage?
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Toni78 wrote:
Simply tell the dialog to shut up and I don't know what could be wrong with you. What kind of symptoms are you experiencing?
Have you ever thought about doing psychology?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
Have you ever thought about doing psychology?
Actually, I am an "engineer" but since I cannot find a job I think I should consider your suggestion. It would be so much fun to play with peoples' minds and tell them that they are crazy when they're just fine.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|