|
I have two menu items under the File menu - Call My Dialog & Call MessageBox. Call MessageBox will invoke a message box. I am trying to do the same thing when the user hits Call My Dialog menu item.
void CMainFrame::OnFileCallmessagebox()
{
MessageBox(_T("hello world!!"), _T("Sample message box"));
}
void CMainFrame::OnFileCallmydialog()
{
HWND hwnd = AfxGetMainWnd()->GetSafeHwnd();
::SendMessage(hwnd, WM_COMMAND,
HIBYTE(ID_APP_CALL_MESSAGEBOX),
LOBYTE(ID_APP_CALL_MESSAGEBOX));
}
Whatever I do I keep getting some failure assertion
|
|
|
|
|
deostroll wrote: Whatever I do I keep getting some failure assertion
First thing to do is look at the assertion message and figure out what is going wrong; or post it here so we can help you.
Secondly your ::SendMessage[^] syntax is not correct.
Thirdly, why not just tie both menu items to the OnFileCallmessagebox() function?txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
suppose I had a modal dialog box. I click a button on it, I'd want to call the same routine (i.e. the Call Message Box click event) via SendMessage(). Is this not possible?
I've rewritten and debugged my code...and found out that the values I am sending for wParam and lParam are wrong
this->SendMessage(WM_COMMAND,
HIWORD(ID_APP_CALL_MESSAGEBOX),
LOWORD(ID_APP_CALL_MESSAGEBOX));
what are the correct values?
|
|
|
|
|
deostroll wrote: suppose I had a modal dialog box. I click a button on it, I'd want to call the same routine (i.e. the Call Message Box click event) via SendMessage().
I have no idea why you would want to do this. A modal dialog provides a break in an application where the user is asked for some information, or to make a decision, before returning to the main application. If your dialog needs to call another dialog or (terrible idea) itself, then your design is flawed.
deostroll wrote: what are the correct values(for SendMessage() )?
I cannot be certain, but I suspect it is something along the lines of
this->SendMessage(WM_COMMAND, ID_APP_CALL_MESSAGEBOX, 0L);
I suggest you take a look at the MSDN Documentation[^] for further information.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
What if the dialog was non-modal? Wouldn't this be a valid scenario? Btw how do u do a modeless dialog box?
|
|
|
|
|
deostroll wrote: What if the dialog was non-modal?
The same considerations apply; it's a question of design and usability. If I am running an app on my PC and select a menu item which pops up a dialog box, and then press a button on that dialog which pops another dialog, I tend not to feel too kindly towards the designer. As I said before you need to understand what dialogs are for and use them sparingly. Programs that just throw dialogs and other clutter at users tend to be consigned fairly quickly to the dustbin of history.
deostroll wrote: Btw how do u do a modeless dialog box?
You read the MSDN documentation[^] to start with.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hey, I don't mean to call another dialog from another dialog. I just put a messagebox in one of my menu item's event handler. It is just to test if the code executes...which it apparently does not?
k, on the topic on non-modal dialogs I don't understand the difference between the following 2 snippets:
CMyDialog* dlg = new CMyDialog();
dlg->Create(IDD_MY_DIALOG);
dlg->ShowWindow(SW_SHOW);
CMyDialog dlg = new CMyDialog();
dlg.Create(IDD_MY_DIALOG);
dlg.ShowWindow(SW_SHOW);
Snippet 2 doesn't work! Why is that so?
|
|
|
|
|
deostroll wrote: Snippet 2 doesn't work! Why is that so?
I don't really know MFC that well, but I guess the CMyDialog() constructor returns a pointer to a new object. Sorry, senior moment there, new returns a pointer to the object created. You can check what actually happens when you run your app by using the debugger.txtspeak is the realm of 9 year old children, not developers. Christian Graus
modified on Friday, February 12, 2010 12:11 PM
|
|
|
|
|
Richard MacCutchan wrote: If I am running an app on my PC and select a menu item which pops up a dialog box, and then press a button on that dialog which pops another dialog, I tend not to feel too kindly towards the designer.
Really? This sort of thing happens all over Windows (XP and Vista), Office (2003 and 2007), IE (6 and 8), Visual Studio (6 and 2005), etc."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
DavidCrow wrote: This sort of thing happens all over Windows, Office, IE, Visual Studio, etc.
Strange, it doesn't on the versions I have!txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hi All,
Is it possible to open the file twice? I am using CStdioFile, i created two objects of type CStdioFile and assigning the same file for both the objects. one file opened for writing(modeReadWrite) the data and the other file opened for reading(modeRead) the data. In this case my application is crashing. please give me some solution.
CStdioFile obj1;
CStdioFile obj2;
obj1.Open("file1.txt", CStdioFile::modeReadWrite);
.....
.....
.....
obj2.open("file1.txt", CStdioFile::modeRead);
.....
.....
obj2.close();
....
...
obj1.close();
Thanks in advance!
Regards,
Anil
|
|
|
|
|
Why do you want to do such a thing ? Why don't you simply open and read the full file in memory, make the changes in memory and then write back everything to the file afterwards ?
|
|
|
|
|
|
Member 4399771 wrote: In this case my application is crashing.
At what point?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Yes you can, simply use 2 handles (or objects or whatever your language wants you to use). Be aware of the folloing:
- The OS sees this as file sharing, so open in shared mode.
- You will have 2 independent filepointers.
Rozis
|
|
|
|
|
To Cedric and David: There are many cases opening a file twice can be handy. The simplest example is a Word document on a network. The first user reads it shared, read-write, the next shared, readonly. Be aware many DBMS use this for concurrent access (with some intelligence around).
Rozis
|
|
|
|
|
Hi..
In CView application I am showing a dialog(Like toolbar/ Status bar).
I have to change the dialog background color.
I used the following code. But background color not changing. If i use this same in new dialog application the background color is changing.
ON_WM_ERASEBKGND()
BOOL CTech::OnEraseBkgnd(CDC* pDC)
{
CRect rect; GetClientRect(&rect);
CBrush myBrush(RGB(255, 0, 255));
CBrush *pOld = pDC->SelectObject(&myBrush);
BOOL bRes = pDC->PatBlt(0, 0, rect.Width(), rect.Height(), PATCOPY);
pDC->SelectObject(pOld);
return bRes;
}
How to solve this problem.
Any help will be appriciated..
Thanks...G.Paulraj
|
|
|
|
|
I do not think that this is the message for the dialog's background repaint. Take a look at the WM_CTLCOLORDLG[^] notification. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
It is working fine in form based applications... G.Paulraj
|
|
|
|
|
Paulraj G wrote: It is working fine in form based applications...
What has that to do with a Dialog? Did you follow the link I posted, and try using the methods suggested by Microsoft?txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hello,
I am using VS2008 and OS Win XP. I create one application and uses the following function for writing the CD and it works fine.
SHGetFolderPath();
CoCreateInstance();
pICDBurn->HasRecordableDrive();
pICDBurn->GetRecorderDriveLetter();
pICDBurn->Burn();
When i deploy this application on OS Windows 2000, these function fails.
Is Win 2000 does not support this API or functions?
If i have to write CD in win 2000, what changes i have to made in this application or any other way to write CD?Abhijit
|
|
|
|
|
Usually error handling is helpful in such cases.
However, reading the
Minimum operating systems=Windows XP
info in the documentation [^], is priceless.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for your help.
Is there any other way to write CD on Win 2000?
|
|
|
|
|
Probably there is, unfortunately I haven't found it (for instance IMAPI too are not supported).
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
How to hide the dialogbox in win32. I tried ShowWindow(hWnd,0) in Initdialog()but fails to hide.
|
|
|
|