|
can you point me the difference beetween:
Option m_Option;
m_Option.DoModal();
and:
m_Option = new Option(this);
m_Option->DoModal();
Both work but what is the difference "new" create a new instance ?
but if I "new" something I assume I should delete it somewhere ?
I'm a bit lost here while MFC do so much things automaticly
I don't want to miss something and to get memory leak.
Thanks
|
|
|
|
|
The difference is that m_Option is obviously a member variable to a pointer, Option is just an istance of the dialog. You never call delete on a CWnd, you call DestroyWindow, which ( I believe ) will be called for you in the case of a modal dialog. You should definately set m_Option to NULL after the DoModal though, and also in your constructor, for safety.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
In your option 's ::PostNcDestroy()
add :
delete this;
no memory leak;
|
|
|
|
|
Thanks
|
|
|
|
|
I hope somebody can help me with this (before I tear all my hair out and/or reformat my disk and reinstall everything)
For the last week or so, every now and then, as I am working in Visual Studio, I get a dialog labelled "MSDEV.EXE - No Disk", with the message "There is no disk in the drive. Please insert a disk into drive \Device\Harddisk1\DR2.". Three buttons, labelled "Ok", "Cancel" and "Try Again" each seem to do nothing, I need to terminate Visual Studio via the Task Manager to clear the message. Sometimes there is a considerable time (Hours) between stating Visual Studio and when this happens, other times it may only be a few minutes. I have uninstalled and reinstalled Visual Studio to no avail. I would suspect the hardware, except that no other application is failing in any way! BTW, I am running Windows 2000 Professional, on a new computer. I never had a problem like this on my previous machine.
Regards,
Gunter
Gunter F. Maywald
CSIRO Entomology
Long Pocket Labs, Brisbane
Australia
|
|
|
|
|
In Tools -> Options, you can go to the Directories tab and see where it's looking for things. If there are duplicate paths that don't exist anymore then you can just delete them from there and you'll have no problem anymore.
|
|
|
|
|
Hi,
I have two variables with types CString and int.
int nWidth;
CString strWidth;
strWidth = "110";
How do I convert strWidth("110") to int type(110) so I can store it in nWidth?
Please show me how to do this, thank you very much.
|
|
|
|
|
use the atoi or atol functions.
iWidth = atoi(strWidth);
|
|
|
|
|
Or you could use strtod() and strtol().
strtol() is useful if you want to read a number that is not in base 10. For example
to read hex numbers use strtol("0x12345678", NULL, 16)
_tcstol() and _tcstod() are the macros for UNICODE/MBCS portability
Stephen Kellett
--
C++/Java/Win NT/Unix variants
Memory leaks/corruptions/performance/system problems. UK based.
Problems with RSI/WRULD? Contact me for advice.
|
|
|
|
|
int nWidth = 110; <br />
CString strWidth; <br />
strWidth.Format ( "%d", nWidth );
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Use function StrToInt this way
int nWidth=StrToInt(strWidth);
just one line of code and u got inr value.;)
Gonna be 18 till I die
|
|
|
|
|
Two problems. First, why use a non standard function when atoi works perfectly well, and second ( from MSDN)
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with Internet Explorer 4.0 or later).
Windows 95/98: Requires Windows 98 (or Windows 95 with Internet Explorer 4.0 or later).
Sounds like a bad idea to me, unless you specifically do not target the platforms not supported, and even then I would personally prefer not to get into the habit of using something I may find unavailable to me down the track, for no good reason I can see.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I need to color 3D graphic object, the graphic object is described by multiple triangles in variable size. I need to color this 3D object. Color will be variable based on the different
heighth (Z coordinate) of the 3D dimension, but the parts which are in the same height must be in the same color. How to color this graphic object? Please help me.
|
|
|
|
|
Since you can set a color for each vertex of the mesh, this doesn't seem to be a problem. Just set the color as a function of the z for each vertex :
...
glColor3f(R(z),G(z),B(z));
glVertex(x,y,z);
...
where R,G,B are mapping of z
Jonathan de Halleux, Belgium.
|
|
|
|
|
I am currently writing a Dialog based application that sits atop a database. In the summary screens I use a ListCtrl to display all records from a given table that can be selected to then take us to the detail screen. Using advice previously administered from this forum I have set the width of column one to zero, this is to hide the tables Primary Key from the user, while still having it available to me to use when next accessing the record in the database.
In a particular table I have an Order column for use in reports that the user, uses to set the order. I want to create a seperate screen where the user can reorder the records. This is where I have run into my current problem, how do I achieve this what is the best control for me to use.
I envisaged using the ListCtrl, which has become my friend in this project. I would display the Customer (with hidden Primary Key), allow them to re-order the list and then I would cycle through the records updating them sequentially with the new order value.
Problem is the SetItemPosition() function only works when in Icon or Small Icon mode and SetExtendedStyles only has drag and drop ability on rows not columns. Of course I am using Report mode and need to re-order the rows not columns. This stops me from using drag and drop or Up/Down command buttons to enable the re-ordering.
I also thought about using a ListView, but if I didn't want to have the Primary Key visible I would have to create a map and store it in an array external to the ListView. This would force me to keep track of the order of two things to achieve the result I want. Thats one to many for my brain that is running low on RAM at the moment.
What have I missed? I'm sure it is obvious, but not to me. How should I be doing this? Preferably I would like to be able drag the row into it's new position. Any help much appreciated. What's the answer?
Thanks in advance for the help.
P.S. All humour, sarcasm and colloquialisms removed so as not to confuse or offend. Also as a test to see if this question gets an answer this time.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
The only built-in control that does drag & drop of rows is CDragListBox, but that's derived from a listbox (old Win 3.1 control) not a list view control, so if you need to keep the report style UI of the list view control, CDragListBox won't do it for you.
The list view control doesn't have any built-in reordering support, unfortunately. (Well, version 6 of the common controls does, but that only works on XP.)
--Mike--
http://home.inreach.com/mdunn/
"Holding the away team at bay with a non-functioning phaser was an act of unmitigated gall. I admire gall."
-- Lt. Cmdr. Worf
|
|
|
|
|
Mike
thanks for the help CDragListBox seems to be what I was looking for. MSDN says that I can have columns and set their width so I should be able to keep the Primary Key in the row data which is what I was looking for. It also tells me that I just add a ListBox to my dialog in the editor and then in ClassWizard set a control variable of type CDragListBox. Problem is that I only have CListBox as a choice. I am going to add CListBox and then manual edit the code to use CDragListBox and hope that this works.
Any idea why these other choices aren't appearing? Is it a setting I can modify or maybe a header I am missing in the project?
I have noticed other strange things that have hapened over time. A couple of years ago when I would create an app with a DropList ComboBox I would have the option of selecting a CString as a value variable, while now I only get int. I then have to change the int to CString and hack the DDX section of the code to get it to return the selected string and not zero based index when I do UpdateData(TRUE);
Did these changes appear while I was sleeping for the past couple of years or have I just screwed up something simple yet again?
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
I need to print a metafile to a specified rectangle on the printer DC. I am using the PlayEnhMetaFile(...) function to paint the metafile to the DC. This works except the RECT passed into the API call is in logical units (I believe) and the printer DC is something else. How do I get one or the other into the same coordinate system?
TIA!
|
|
|
|
|
hello everyone,
here is my situation. I have a document view app. in the view I create an edit control programatticaly and make it appear at a certain point. When I call CEdit::create I pass "this" as the parent window. Thus, the newly created edit control is a child of the view (i think). What I want to be able to do however, is when I click back on the document the text box which pops up should dissapear. However this simply doesnt happen, its as though the popped up text box is modal to the view. I think this is happening because the text box is being created "on" the view it is almost as if the view doesnt lose focus. Thus, clicking back on it doesnt cause the view to throw any focus related messages... Hope this is clear....
Andreas
|
|
|
|
|
Yes, of course. That's how controls work. The problem is that your view cannot have focus by itself. The easiest way to do this would be to handle the onclick event of the view and deactivate the edit control.
|
|
|
|
|
I have been looking at how I would do this and keep on finding the same code - that you would derive from CEDit and override WM_CHAR messages, and check for VK_ESCAPE, however take a look at this code:
void CEditExtended::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
MessageBox("Character message thrown!");
switch( nChar )
{
case VK_ESCAPE :
{
MessageBox("Escape");
break;
}
case VK_RETURN :
{
MessageBox("Return!");
break;
}
default :
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
break;
}
}
CEdit::OnChar(UINT nChar,UINT nRepCnt,UINT nFlags);
}
Pressing the escape key simply isnt throwing these messages, why would this be?? Any idea how I can do this? (i know everything else is it set up right because if i press another key then this function gets called so its nothing like that)
any help very much appreciated!
thanks
|
|
|
|
|
Hi Anon,
I think you might find that your App (which I suspect is a wizard generated Dialog App) is actually generating a WM_CLOSE or WM_CANCEL. The easiest way to fix your problem is to put a check in you OnClose method.
It should look something like :
if (GetKeyState() & VK_ESCAPE = VK_ESCAPE)
return;
CDialog::OnCancel();
Let us know if you getting it working & how.
Julien.
|
|
|
|
|
Opps
Try this :
BOOL CYourDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
//////////////////////////////////////////////////////////////
// Prevent Enter and ESC from closing the control.
//////////////////////////////////////////////////////////////
if (wParam == IDOK)
return FALSE;
if (wParam == IDCANCEL)
return FALSE;
return CDialog::OnCommand(wParam, lParam);
}
J
|
|
|
|
|
One way to catch the escape key is to overide PreTranslateMessage and before calling the base class PreTranslateMessage, look for a message w/msg = WM_KEYDOWN and wParam = VK_ESCAPE. Then, I usually translate the message into a MYMSG_CUSTOM_ESCAPE message and post that message back to me and return without calling the base class. See sample below.
BOOL CMyWnd::PreTranslateMessage(MSG* pMsg)
{
BOOL bCallBaseClass = TRUE;
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)
{
PostMessage(MYMSG_CUSTOM_ESCAPE);
bCallBaseClass = FALSE;
}
if (bCallBaseClass)
BOOL CWnd::PreTranslateMessage(pMsg);
return TRUE;
}
LRESULT CMyWnd::OnMyCustomEscape(WPARAM wParam, LPARAM lParam)
{
// TO SOMETHING
return 0;
}
|
|
|
|
|
My "this" pointer in my DLL is getting f*ck up,.. I don't know why.
I have create a small 72K zipped test application and dll that shows
this problem.
download it here.
www.marino.dk/misc/dlltest01.zip
run the application, and click on the 'help' menu and then the 'testme2'
menu item. Here you should get an example of a "this" pointer being destroyed.
Plz somebody help me,
Peter Marino ( IO Interactive )
www.marino.dk
|
|
|
|