|
Maybe Paul DiLascia can help you:
MSDN - Periodicals 1999 - MSJ - April - Q & A C++
|
|
|
|
|
Hi All,
I'm trying to put together an application that will alow the user to have a bunch of screens open at the same time. Most of these will be some sort of form view, but all related, ie these are all tied to the same document. One screen, let's say would ask the user for their address and phone number, and the next maybe some other information.
Navigation from one entry screen to another will be directed by a tree control on a dialog bar docked on the left side of the main frame, where each of the leaves of the tree represents a distinct screen the user would need to visit.
So, what's the way to have one document, and several views, any one of which could be open or not at a given time?
Thanks,
Aaron
|
|
|
|
|
If you want to know how to have one doc with several view check this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
There are several ways to do this, but here's mine:
Create a spitter with the tree view in the left pane and a CView derivative (CYourView : public CView) in the right one. When the CYourView window is created (CYourView::OnCreate()) you create as many child views as you have different types of form views. Each child view is of course derived from CFormView. Create the child views invisible (either with a zero size or without the WS_VISIBLE style). Now, each time you make a selection in the tree view you send a message to CYourView, which in turn hides the current displayed child view and shows the new one, filling it with the relevant data. If you set up a CCreateContext structure and pass it to the child view on creation they will behave exactly like ordinary views.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi,
I create a MFC Application with the wizard, SDI / MDI. After I compile, some dialog boxes and the print preview are in french??? I know that I have french software on my computer but my XP is in English as is my VS6. I would like to compile my apps in english please. If you want me to send you a file, ask me.
Boxes in french (the one I found):
-Open
-Save
-Save As
-New
-Print
-Print Preview (everything in there)
-... etc.
// JS Paquet
cout << "Thank you all" << endl;
|
|
|
|
|
I'm having problems getting rid of a memory leak in my application. It has the potential to be a huge problem in the application but I don't know what I can do to get rid of it. I've tried everything I know. Here's the code where the leak is coming from:
for(i = 0; i < FormationSize; i++)
{
ar >> PositionID;
((CText*)PositionID)->SetTextFont(&lf);
(*FormationPositions)[i]->PositionIdentifier = AdjustPositionLocation(PositionID, OpenViewBottomRight);
ar >> (*FormationPositions)[i]->PositionType;
}
FormationPositions is a parameter that is passed by reference to the function containing this code and it is a pointer to a vector where each element in the vector is composed of two parts--a pointer to a Text element and a CString. What I'm doing is reading in information from a saved off file and storing each element in the vector. I'm not sure what I'm doing wrong, but when the application closes, each element of the vector is listed in the memory leak. This code is executed each time a file name is selected from a dropdown box so for each instance of a file being selected from the dropdown box, there are that many sets of vector elements listed in the memory leak. Sorry if this is a bit convoluted. It's hard for me to explain it with any degree of competency. As you can see, I'm not that smart.
Any ideas? Need more info?
|
|
|
|
|
When the vector goes out of scope, it does not call delete on these pointers. You need to do that yourself, probably with for_each.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
If I'm understanding you correctly, the vector is storing a struct/class that contains a pointer to a Text element and a CString. The main question is, are you destroying the memory pointed to by each Text element pointer when the program closes? This would be done in the destructor for each struct/class.
CodeGuy
The WTL newsgroup: over 1200 members! Be a part of it. http://groups.yahoo.com/group/wtl
|
|
|
|
|
Maybe I can try to explain it a little more clearly. What's happening is I'm passing in the vector containing 11 struct elements, each of which is comprised of a pointer to a Text element and a CString. What I'm trying to do is replace the 11 elements in the vector with 11 new elements each time a file is selected by the user from the dropdown box. My problem is that I'm coming up with 11 new elements that are causing the memory leak.
For example, the program starts and the user selects a new file, then he selects another new file later during program execution. When the application exists, there are 22 elements listed in the memory leak information. On the other hand, if the user just fires up the application and uses any/all of the functionality except for using the dropdown box, when the program exists, everything is fine...no memory leak. The elements are destroyed in the destructor.
Any new thoughts?
|
|
|
|
|
No new thoughts, just the same ones.
You have a pointer to a Text element in the struct. What it sounds like you're doing is calling 'new' to allocate memory for each Text element every time the file is selected from the combo box.
What you have to do is 'delete' the memory used by the Text elements each time you reselect a file. The vector only manages memory for the struct; it doesn't manage memory for elements inside the struct like the Text element.
The CString of course is not a problem because it manages its own memory.
CodeGuy
The WTL newsgroup: over 1200 members! Be a part of it. http://groups.yahoo.com/group/wtl
|
|
|
|
|
Arg.. I am having the hardest time with writing a CPropertySheet program. I am working with 3 different classes which are derived from CPropertyPage. I am trying to figure out how to make it so when you click OK on any of the pages it causes data validation on all of the pages.
I thought that I could override the OnOK() function of page1 such that it will call UpdateData() for page2 and page3, however an assertion error occurs if you call UpdateData on a PropertyPage that doesn't have focus. And I can't write a function for each page that sets itself as the active page as the (CPropertySheet*)GetParent() wont work since its called from another page and not the sheet.
So then I thought that on the OnInitDialog() of page1 I would set member variables(pointers) which point to the PropertySheet and each of the pages, such that each page would have member variables (pointers) to both the PropertySheet and each of the pages. But when I try to compile I get tons of errors in my headers where I define the pointers:
public:
CPropertySheet *pSheet;
CPropPage1 *pPage1;
CPropPage2 *pPage2;
CPropPage3 *pPage3;
It doesnt mind the CPropertySheet pointer member variable, but it gives the error "error C2143: syntax error : missing ';' before '*'" for each of the other pointer declarations even though right above i have the includes:
#include "PropPage1.h"
#include "PropPage2.h"
#include "PropPage3.h"
Why is it that it wont let me create member variables which are pointers to my user defined classes? Why is it such a pain in the butt to make is so that the OK button on a CPropertySheet does validation on each of its pages instead of just the one that is being displayed? And why have I wasted the last 3 hours on something that seems like it would be so easy!
Thanks for any help you can provide this newbie.
-dz
|
|
|
|
|
If you want to look at my sample download the project at:
www.dzgraphics.com/PropSheetTest.zip
Use the 'test 2' button on the toolbar
-dz
|
|
|
|
|
How can I create splitter windows using SDK.
|
|
|
|
|
Splitter windows is a MFC thing, not a SDK one. If you want to do splitter windows only using SDK you'd have to write all the functionality yourself.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I want to share some dialog resources to several apps.
I share my dialogs from a MFC extension DLL.
I keep getting the same problem with modeless dialogs.
When calling the CDialog::Create(), a blank dialog is shown. I have no problem accessing its child windows.
But there are simply not visible.
Displaying a Modal dialog works fine, the dialog is showed correctly...
Any ideas ?
|
|
|
|
|
I think MFC Tecnhical Note 11 addresses your problem. Quote follows:
Note that the CWinApp::Run mechanism doesn't apply to a DLL, since the application owns the main message pump. If your DLL brings up modeless dialogs or has a main frame window of its own, your application's main message pump must call a DLL-exported routine that calls CWinApp::PreTranslateMessage
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am trying to write my own dialog class, but I'm having some problems conserning the dialogproc.
When my class creates a dialog with DialogBox() all messages are handles by the dialogproc. However I want the dialogproc to call an On... method of the dialog class for every message. For this the dialogproc has to have a reference to the instance of the class. My question is how do I pass the class reference to the dialogproc?
I could create a global or static member variable to hold the reference, but this is a problem when there are multiple instances of the dialog; the member variable will be overwritten.
Does anyone know a sollution for this problem?
regards,
Brian
sample code:
CAboutDialog* thisDialog = NULL;
int _stdcall DialogProc(HWND hwndDlg, //!< handle to dialog box
UINT uMsg, //!< message
WPARAM wParam, //!< first message parameter
LPARAM lParam //!< second message parameter
)
{
BOOL handled = FALSE;
if (thisDialog != NULL)
{
switch(uMsg)
{
case WM_INITDIALOG:
thisDialog->OnInitDialog(hwndDlg, wParam, lParam, handled);
break;
case WM_PAINT:
thisDialog->OnPaint(hwndDlg, wParam, lParam, handled);
break;
case WM_COMMAND:
thisDialog->OnCommand(hwndDlg, wParam, lParam, handled);
break;
}
}
return handled;
}
|
|
|
|
|
Try makin DialogProc a member function of your class. Or is that not allowed cause of the way it's prototyped?
If so create a PreDialogProc static member function with an extra 5th param that takes a class pointer. Now use this class pointer to call the class member dialog proc passin the first 4 params.
Nish
CPUA # 0x0666
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Thanks for your reply but I already found the answer. Instead of using DialogBox to create the dialog I should use DialogBoxParam. This allows you to pass the this pointer of the class in the lparam of the WM_INITDIALOG message. Problem solved.
|
|
|
|
|
Store a pointer to your dialog class in the window data field of the actual dialog window.
Use the SetWindowLong function and set the GWL_USERDATA field.
Then in your static member function of the dialog class that you are using as your dialog proc function, call:
<br />
CYourDialog *pDlg = dynamic_cast<CYourDialog*>(GetWindowLong(hWnd, GWL_USERDATA));<br />
if (!pDlg)<br />
{<br />
}<br />
<br />
<br />
This trick will also work for regular windows. If you already have data stored in the USERDATA field, then you can simply convert this data to a structure and include the pointer to your object, or move the data into your class and still hold the this pointer in the USERDATA field.
|
|
|
|
|
I'm trying to add a drop down menu to a button using Windows SDK not MFC.
Thanks
|
|
|
|
|
I guess <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/CommCtls/winui/menus_0hdi.asp">TrackPopupMenu</a> is the place to start from.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You need to create and track a popup menu in response to the button click. See CreatePopupMenu() and TrackPopupMenu.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
I'm migrating from GDI to GDI+ under Visual C++ 6.0.
I was calling SetPixelV on a device context. Now with a HDC and a graphics object, how to do a SetPixel ?
Thanks for your help
Nicolas
|
|
|
|
|
I don't know the answer,but Christian Graus has some articles about GDI+,put message there ,maybe he knows it.Check this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|