|
hi everybody,
i designed a dialog which i'd like to close by right-click anywhere inside it. For that, i overrided the WM_RBUTTONDOWN an i associated to it the following code :
<font style="color:blue;">void </font>CAboutDlg::OnRButtonDown(UINT nFlags, CPoint point) {
<font style="color:blue;">this</font>->OnClose();
CDialog::OnRButtonDown(nFlags, point);
} Unfortunately, it doesn't work
i've been obliged to create a "OK" button which i hide, and instead of calling OnClose (), i call OnOk () :
<font style="color:blue;">void </font>CAboutDlg::OnRButtonDown(UINT nFlags, CPoint point) {
<font style="color:blue;">this</font>->OnOk();
CDialog::OnRButtonDown(nFlags, point);
} It now works, but i don't like this way of contourning the problem.
can anybody tell me why my first code doesn't work, and what i could do do resolve th pb ...?
TOXCCT >>> GEII power
|
|
|
|
|
Why not call EndDialog()
Ant.
|
|
|
|
|
work fine thank you
anyway, do you have an idea of the reasons OnClose () doesn't work ?
would the virtual BOOL CWnd::DestroyWindow(void); have work better too ?
TOXCCT >>> GEII power
|
|
|
|
|
You would use DestroyWindow() for a modeless dialog and EndDialog() for a modal dialog.
OnClose() will call DestroyWindow() anyway IIRC. However without looking I can not recall why they are done differently. Now I will have to look and find out
Ant.
|
|
|
|
|
From MSDN CDialog::OnOK
"If you implement the OK button in a modeless dialog box, you must override the OnOK method and call DestroyWindow from within it. Do not call the base-class method, because it calls EndDialog, which makes the dialog box invisible but does not destroy it."
Had to look this up so here for your benefit too.
Ant.
|
|
|
|
|
thx very much
TOXCCT >>> GEII power
|
|
|
|
|
You can do it like this:
<br />
void CAboutDlg::OnRButtonDown(UINT nFlags, CPoint point) <br />
{<br />
SendMessage(WM_CLOSE);<br />
<br />
CDialog::OnRButtonDown(nFlags, point);<br />
}<br />
and then in OnClose(), you can do the cleanup. OnClose() is called after WM_CLOSE is processed, I guess. So it doesn't actually close the window.
|
|
|
|
|
ok. yes, i was calling OnClose () to close, but it is called when the windows is about to be closed... thx
TOXCCT >>> GEII power
|
|
|
|
|
Any reason why OnRButtonDown() is calling OnLButtonDown() ?
toxcct wrote:
Unfortunately, it doesn't work
Because EndDialog() is not being called. Take a look at CDialog::OnOK() and CDialog::OnCancel() . Notice how they both call EndDialog() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
DavidCrow wrote:
Any reason why OnRButtonDown() is calling OnLButtonDown()?
Nop, mistake from my own. fixed now. thanks for the directions to see.
TOXCCT >>> GEII power
|
|
|
|
|
|
thank you but repost.
no need to overload the servers...
TOXCCT >>> GEII power
|
|
|
|
|
I am working on an SDI application with 3 different views(CFormView). There are 3-4 variables that are shared between those views. These variables should be saved in a file, so each time user starts the app its sees the interface as it was when he exited.
I don't need to use CDocument, because I need just one file to store the settings for the app. Therefore, my questions are:
1) Where should I put those variables (CwinApp, CDocument or somewhere else)?
2) What other changes do I need to make, in order to have the app load the settings' file, when it starts, and save changes to the file when it exits?
3) How to 'turn off' support for creating new, opening and saving documents, since I don't need it?
Any help would be appreciated.
|
|
|
|
|
Yes, I recommend CDocument. The concept of SDI utilizes CDocument. Access CDocument through the view.
Kuphryn
|
|
|
|
|
If you don´t necessarily need a file, what about the registry, otherwise you could use the applications´ ini file.
1) If the Views are using the same CDocument and you don´t need these variables anywhere else than in these view, you might as well put them in CDocumen, otherwise in CWinApp
2) The CWinApp object gives a halfway decent support to write an read from the ini file
CWinApp::WriteProfileInt
CWinApp::GetProfileInt
CWinApp::GetProfileString
CWinApp::GetProfileString...
when the app quits, you can write your stuff within the
virtual CWinApp::ExitInstance()...
3) Easiest thing to do is to throw out the resources directly from the menu.
|
|
|
|
|
Thanks for your input. I'll probably opt for registry.
|
|
|
|
|
I have a 3 questions for any of the experts out there but first here is some code...
I wrote the following code in C# for reading absolutely any file type. It does work perfectly for any file type and the method or style is called a binary file reader....
byte[] buffer = new Byte[SizeBuff];
int bytesRead = 0;
int ByteCounter = 0;
inputStream = File.OpenRead(@InputFile.Text);
while ((bytesRead = inputStream.Read(buffer,0,SizeBuff)) > 0)
{
ByteCounter = ByteCounter + bytesRead;
}
int TotalBytes = ByteCounter;
byte[] ModifyThisFIle = new Byte[TotalBytes];
int KiloByteCounter = 0;
inputStream.Close();
inputStream = File.OpenRead(@InputFile.Text);
while ((bytesRead = inputStream.Read(buffer,0,SizeBuff)) > 0)
{
for (int a = 0; a < bytesRead; a++)
{
ModifyThisFIle[a + (KiloByteCounter * 1024)] = buffer[a];
}
KiloByteCounter = KiloByteCounter + 1;
}
Does Visual Studio C++ .Net use the same exact method and code to read any files especially when you would be opening NON text files such as JPG, PDF, HLP so an so forth???
Is the method called a binary file reader???
Do you have a link to any such functional code???
Thanks,
demasoni.com
Elite
|
|
|
|
|
Demasoni.com wrote:
Does Visual Studio C++ .Net use the same exact method and code to read any files
you can use open() , fopen() , ifstream ...
Demasoni.com wrote:
especially when you would be opening NON text files such as JPG, PDF, HLP so an so forth???
you read a stream of bytes, then you interpret these bytes the way you need.
Demasoni.com wrote:
Is the method called a binary file reader???
if you like... but effecdtively, if you read binary datas, you can call this a binary file reader...
TOXCCT >>> GEII power
|
|
|
|
|
No, you must have have miss understood my question. The ifstream and open are very simple concepts. I was refering to all of the statements within and including the WHILE LOOPS.
So any way I will ask it again maybe a little differently, does my C# code for Binary File Reader work for VC++ to read at the binary level or is there another method of reading binary files like JPG, PDF, HLP like that. "Within And Including The While Loops"???
I gave my functional C# example. What would the code be for VC++ ???
Thanks,
demasoni.com
Elite
|
|
|
|
|
Hi..all...
Can you provide code snippet to verify ISBN/UPC...
Thanks
---Sumit Kapoor---
|
|
|
|
|
http://www.cs.queensu.ca/home/bradbury/checkdigit/isbncheck.htm
http://www.cs.queensu.ca/home/bradbury/checkdigit/upccheck.htm
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks..very useful example...
but the problem is as second set may contain 2 or 3 digit & third set 5-6.. so that create confusion...
Also if ISBN end with X...
reply me if u've any info about this...
thanks.
---Sumit Kapoor---
|
|
|
|
|
Sumit Kapoor wrote:
but the problem is as second set may contain 2 or 3 digit & third set 5-6..
This does not matter as dashes are ignored.
Sumit Kapoor wrote:
Also if ISBN end with X...
Then the check digit will be 10.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks...You r right...
OK! Bye..see U...
---Sumit Kapoor---
|
|
|
|
|
Hi,
I’m developing an ActiveX-control in VS C++ 6.0 (winXP): works fine.
For deplyment, I’m using VS.NET for making the Cab-file (New project: Cab Project). Adds ocx and builds Cab: works fine.
Problem: ocx is depending on 2 other dlls, as it is now they are downloaded and registered manually: this works some times, some times it is "Dll Hell".... "Dll hell" occurs when updating ocx and dlls.... is there any way to force registration and so on? My belive is that it will work fine if I just adds the dll to the Cab File-project, could that be rigth? If so, how do I do it in VS.NET (I know how to add the files, but it’s not working when adding the depending dlls)?
I’m also a bit confused of the making of the Cab File, with VS.NET (Cab Project, OSD-file) it’s easy, but I dont know what I’m doing... old tech, with INF-file, it was harder, but more open I guess?
Which is the best solution in my case?
...and justice for all
APe
|
|
|
|