My apologies; I should have been clearer on that point. When I click on the Print button on the property sheet, it gives me an access violation (Error code: 5) when I'm in debug mode.
bcemick
Posts
-
A virtual function question -
A virtual function questionThe functions I need to access are public and declared as virtual. That's the first thing I checked.
public: UINT virtual NewDocument();
It's not that I hate object orientation; I've just never understood the point of virtual functions. I don't understand why you would want to use them. Christian Graus wrote: Is it possible to put code that defines the interaction between these two objects into a third class, so that they don't become tightly coupled ? Not at this time, although that is a possibility later on. For right now, though, I have to get it working this way. -
A virtual function questionI've looked around trying to find this information, but there's nothing I can find that fits my situation. I have two separate classes: Print and PropertySheet that are part of a larger program. I didn't write the code for either one and making any radical changes is out. All I need to do is add a function to the PropertySheet class that will access the Print class and print out certain information obtained from PropertySheet. Here's the problem: All of the print functions in Print (such as starting a new document, starting a new page, etc) are virtual functions and I can't access them from the PropertySheet class. I've never cared for vf's and haven't worked with them or used them before, so I'm lost on how to do this. Here's the question: How can I access those virtual functions in Print from PropertySheet without re-writing the program (I just want to add the code to print in the PropertySheet class)? I apologize if this has been addressed before, but, as I said, I couldn't find anything for this situation. I appreciate any help and say thank you in advance anyone that responds.
-
Formatting data for a reportThanks for the links and tips. I have read through some of those articles that seemed to be the best ones for what I'm looking for. However, I haven't been able to find any that actually show how the data is formatted for the printed report (unless I missed it somewhere - always possible). I guess I'll just keep combing through them until I come across what I'm looking for or I figure it out for myself. Again, thank you.
-
Formatting data for a report(Using VSC++ 6 - MFC) I've looked through several articles (such as Printing with MFC Made Easy by Dan Pilat) and posts but, the information I'm looking for just isn't there. Plus, this is something that I want to do on my own, I just want to understand how it works; not have someone do it for me. I'm trying to get data from a list control straight to the printer and have it formatted correctly. So far, everything I've tried hasn't worked. I've tried setting up tabs, but the printer prints them out as little squares. I've tried to manually set where each piece of information should print out at (x and y coordinates), but it's not working either, especially if the size of the string being printed changes (it throws everything else off). Basically, here's what I want to set up and what I'm looking for some help with:
Column #1 Column#2 Column #3 (and so on)
Some data here Some more Right-aligned dataBecause this is pretty much how it's coming out (or some variation thereof):
Column #1 Column#2 Column #3 (and so on)
Some datSome moreRight-aligned dataAny ideas on how I can get the information to format correctly? Any help is appreciated.
-
OpenFileDialog....MFCIf you're saying that you just want to open the OpenFileDialog, you could drop in a button and handle opening it from there. Just an idea.
-
Convert Visual Basic to Visual C++If I understand this correctly, you just want to grab the current time and display it in edit boxes. To display the entire date in a single box: (editcontrolstring is the CString variable associated with the edit box.)
CTime tDate = CTime::GetCurrentTime(); CString strDate = tDate.Format( "%B %d, %Y" );//This will give you month day, year _editcontrolstring_ = strDate;
Now, to break it down a little more, you can do something like this:CTime tDate = CTime::GetCurrentTime(); CString strDate = tDate.Format( "%B" );//This gives the month _editcontrolmonthstring_ = strDate; strDate = tDate.Format( "%d" );//This gives the day _editcontroldaystring_ = strDate;
And so on. -
CPropertySheetTry doing in the OnInitDialog of your wizard.
-
Creating buttons and CRect(Kid?) I listened; I really did. I was so sure that I had done it that I almost didn't go check to make sure I had. But, to be on the safe side, I checked. Lo and behold, I had either been attacked by a case of The Stupids and forgotten to do it or deleted it while messing around with it. Either way, thank you for the help.
-
Creating buttons and CRectPJ Arends wrote: did you make your CButton variable a member of your CPropertySheet derived class? ummm....of course I...ummm...you know...umm... :doh: Thank you. I'll go slam my head into a wall repeatedly. Now I just have to figure out how to get into the right place and then line up those other buttons beside it. Which I will. On my own. So I don't look so incredibly dense.
-
Creating buttons and CRectPJ Arends wrote: So there is no way that Create will return TRUE (1) if the HWND is NULL (0). I know. That's what was so weird about all of this. I swear that's what was happening. I tried rebuild all and now it's returning a non-NULL handle; the handle is still invalid though. I tried moving it into another function to see what would happen. I got hWnd handles, but none of them are valid handles according to Spy++. It is still returning 1 (success). The only thing I can think of is that the button is being created, but it's being destroyed before it can be added to the property sheet (if that makes sense - it sounds better in my head). It's either that or I am missing something so obvious that it would've killed me if it was a snake. One way or another, I'm going to make this work. Any help is greatly appreciated (and you've been great so far). If nothing else, it eliminates a possibility.
-
Creating buttons and CRectAccording to the debugger, the hWnd of the button is 0x00000000. Spy++ says "specified handle is not vallid". I knew that as soon as I saw it, but I tried it anyway. So, what's happening here? It's being created (it's returning a non-zero value indicating success), but it doesn't have a valid handle. Is it just being created and then destroyed before getting added to the property sheet? Any ideas?
-
Creating buttons and CRectPJ Arends wrote: Did you remember to add the ON_WM_CREATE() macro to your message map? Yes, I did. According to the step-through, it is entering OnCreate and moving to the Create line for the button. It is returning 1, but that, according to the message, is success. So, it's saying that it is creating it. I just don't know where it's creating it at since it's not showing up anywhere on the property sheet. Everything else that I'm doing in OnCreate and OnInit work. Buttons are removed or moved, the menu is added, all of it; everything except creating the buttons.
-
Creating buttons and CRectAccording to Spy++, none of the buttons (yours or mine) are there. It lists the other things associated with the property sheet, including the OK and Cancel buttons, but the buttons that I'm trying to create (which includes the code you supplied as a test) aren't there. :wtf:This is driving me crazy.
-
Creating buttons and CRectNope; no button. Could it just be that new buttons can't be created directly onto a property sheet? I would think that they could because you can remove buttons or move them around (which I've done). What am I missing here?
-
Creating buttons and CRectThank you for responding. PJ Arends wrote: The parent window of the button should be the property sheet. It looks like you are making the button a sibling of the sheet, not a child of the sheet. Okay, this may be a stupid question, but am I not declaring the parent window as the property sheet? Where am I making it a sibling instead of a child? I changed the ID, but still nothing.
-
Creating buttons and CRectThank you for responding. However... Blake Miller wrote: If this code is IN the property sheet, you problem might be with the GetParent() call. It is indeed in the Property Sheet. I'm trying to create buttons when the Property Sheet is called (or launched). I tried leaving out the GetParent() call, but still nothing. The MSDN says that for creating buttons, the parameters should be: Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID ); I'm curious about something here: if I'm not calling GetParent, how exactly would I reference the parent window? "this" doesn't work and, as far as I can tell, there is no variable for it or really any way to reference it since it's a CPropertySheet class and I need a CWnd class for the 4th parameter. Blake Miller wrote: Keep in mind your child coordinate are relative to upper left corner of property sheet, and not entire screen... The width and height of the Property Sheet are: 700 and 500. That's why I put the coordinates at 690 and 490. As far as I can tell, that should put it in the bottom right corner. Or am I misreading it?
-
Creating buttons and CRectI'm trying to create a button on a property sheet (not a property page). Here's what I have for creating the button: SetWindowPos( &wndTopMost, 200, 100, 700, 500, SWP_SHOWWINDOW );//This is the property sheet window pWnd = GetParent(); m_btnRead.Create("Button Text Here", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, CRect(10, 50, 690, 490), pWnd, 1); The button never shows up anywhere, no matter what coordinates I put in. Am I using CRect incorrectly? Or am I just missing the obvious somewhere? I do apologize for asking this, but I've never worked with property sheets before and I've always just dropped the buttons onto the dialog where I needed them (yes, I was being lazy). Any help is appreciated.
-
More property sheet questionsI think I got it figured out. I needed a separate function for each page in the Property Sheet. But I'm still having a problem with placing buttons on the Property Sheet. No matter what I do, the button will not show up. Any ideas or suggestions are appreciated.
-
More property sheet questionsOh. Here's the code: BOOL CPropertyPage::OnInitDialog() { CPropertyPage::OnInitDialog(); // TODO: Add extra initialization here SetColumnHeaders(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CPropertyPage::SetColumnHeaders() { m_lstPage1.InsertColumn(0, "Text here", LVCFMT_CENTER, 50, -1); m_lstPage1.InsertColumn(1, "Text here", LVCFMT_LEFT, 100, -1); m_lstPage1.InsertColumn(2, "Text here", LVCFMT_CENTER, 100, -1); m_lstPage1.InsertColumn(3, "Text here", LVCFMT_CENTER, 100, -1); m_lstPage1.InsertColumn(4, "Text here", LVCFMT_RIGHT, 100, -1); m_lstPage1.InsertColumn(5, "Text here", LVCFMT_CENTER, 100, -1); m_lstPage1.InsertColumn(6, "Text here", LVCFMT_CENTER, 100, -1); } This is all inside the Property Page class.