|
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
|
|
|
|
|
Hi guys,
I'm having this memory leak problem I do know how to resolve it. Please help.
The program creates a thread and the thread has to use some class members of its belonging class. So I pass the class' pointer to it, when create the thread in the main class CMyDlg:
<code>AfxBeginThread(doThreadProc, this);
In particular, I need to access this class member function, which will return CString value:
<code>
CString CMyDlg::ProcessString()
{
CString resString;
............
return resString;
}
In the thread's function, I use this ProcessString() function.
<code>
UINT CMyDlg::doThreadProc(LPVOID param)
{
CMyDlg *pMyDlg = (CMyDlg *)param;
CString myString;
myString.SetString(pMyDlg->ProcessLabel());
......
}
As it shows I get a memory leak if I do this ProcessString() function in the thread. I won't get that if the function is run in the main class (process). Also, I notice there is also no leak if resString is only declared but never being accessed/manipulated within the function call. In other words, when the ProcessString() function is called by the thread, memory leak will happen if the CString variable (declared in the function) that is manipulated, is the one used to return the function value.
Any ideas?
Thanks alot~
|
|
|
|
|
hi,
CString CMyDlg::ProcessString(){
CString resString; // intialise and manipulate resString ............ return resString;
}
I think u should not return address of local variable.
|
|
|
|
|
This does not return the address of the local variable it returns a copy
Ant.
|
|
|
|
|
Thanks vikrams for the reply,
I see what you are getting. I've always thought that CString is different to PCTSTR or char *. When a function is declared to have return value type CString, it gets its own memory allocation, instead of a pointer to some memory address. So when, in my case, resString goes out of scope upon the function return, the function value still is there (been copied over from resString), in its own space. I'm not sure if I'm right on this point, correct me if I'm wrong.
If I were wrong, I think this would only lead to the loss of data, instead of memory leak. I tried anyway, placing resString as a class member in .h file or as a global variable on the top of .cpp still gives memory leaks
Any more ideas?
BTW: the CMyDlg class is actually a child dialog of some main dialog. It is created in the main dialog's OnInitDialog()
<code>
pMyDlg = new CMyDlg();
pMyDlg->Create(IDD_MY_DIALOG, this);
pMyDlg->ShowWindow(SW_SHOW);
and destroyed in the main dialog's OnDestroy()
<code>
pMyDlg->DestroyWindow();
delete pMyDlg;
if that has something to do with it.
Thanks again.
|
|
|
|
|
If you change
CString myString;
myString.SetString(pMyDlg->ProcessLabel());
to
CString myString(pMyDlg->ProcessLabel());
or
CString myString;
myString = pMyDlg->ProcessLabel();
you should not get memory leaks.
Ant.
|
|
|
|
|
Thanks Antony,
I tried both of them, didn't stop the memory leak
The problem didn't not seem to be on myString, as long as pMyDlg->ProcessLabel() is called in the thread (without saving the return value to anywhere), the memory leak will occur.
|
|
|
|