Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

jschacker

@jschacker
About
Posts
11
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Print CRichEditCtrl from CView
    J jschacker

    The CWnd::Print(…) method will not work. But the CRichEditCtrl knows how to render itself to a device context. The code below will work. I didn’t have a chance to figure out the formatting. You need to look up the FORMATRANGE structure in the MSDN. The code below was cut and pasted for the MSDN article CRichEditCtrl::FormatRange. Also look at the MSDN article Printing in Rich Edit Controls. If you don’t have MSDN you can search Microsoft’s web site. void CPrintChildWindowView::OnPrint(CDC* pDC, CPrintInfo* pInfo) { FORMATRANGE fr; long lPageWidth = ::MulDiv(pDC->GetDeviceCaps(PHYSICALWIDTH), 1440, pDC->GetDeviceCaps(LOGPIXELSX)); long lPageHeight = ::MulDiv(pDC->GetDeviceCaps(PHYSICALHEIGHT), 1440, pDC->GetDeviceCaps(LOGPIXELSY)); CRect rcPage(0, 0, lPageWidth, lPageHeight); // Format the text and render it to the printer. fr.hdc = pDC->m_hDC; fr.hdcTarget = pDC->m_hDC; fr.rc = rcPage; fr.rcPage = rcPage; fr.chrg.cpMin = 0; fr.chrg.cpMax = -1; m_pREC->FormatRange(&fr, TRUE); // Update the display with the new formatting. RECT rcClient; m_pREC->GetClientRect(&rcClient); m_pREC->DisplayBand(&rcClient); CView::OnPrint(pDC, pInfo); } Good Luck, Jonathan Craig

    C / C++ / MFC

  • CDialogBar in CView
    J jschacker

    Look up this document in the MSDN or on Microsoft's web site; "Relationships Among MFC Objects". I keep this one tacked to the wall next to my computer. The function you want is CWnd::GetParentFrame(). Remember the view is a child of the frame. Good luck and happy hacking... Jonathan Craig

    C / C++ / MFC

  • CFileDialog problems on Win2000 with read only files
    J jschacker

    Sorry that this is not a answer to your problem, but I tried creating a dialog app using CFileDialog as the main window. It worked fine in debug mode on read-only files. The only thing I can say is I have Windows 2000 Professional with SR-1 and DevStudio 6.0 with SR-4. Sorry I can't help, Jonathan Craig

    C / C++ / MFC

  • MDI app without MFC?
    J jschacker

    If you really want to do it without any wraper classes (i.e. MFC), get a few books like, "Windows 2000 Programming from the Ground Up" by Herbert Schildt. Herbert likes to hand crank all his stuff and will have examples on how to handle the messaging and window creation. If you just want less complicated CWnd objects you can create a MDI application without the Document/View Architecture. This gives you the CView without the attached CDocument. Unless you want to be able to use different compliers to compile your code, I would use window wraper classes for my development. They do make life easier. Good Luck, Jonathan Craig

    C / C++ / MFC

  • CDialogBar in CView
    J jschacker

    You want to add the toolbar (or dialog bar) to the frame insted of the view. You can catch the button messages in the doc, view, or frame. The code below will add a toolbar to the child frame: int CFrameClass::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) return -1; //Create the toolbar. { EnableDocking(CBRS_ALIGN_ANY); if(!m_wndToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, IDR_TOOLBAR_DEFECTVIEW) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR_DEFECTVIEW)) { TRACE0("Failed to create toolbar\n"); } else { // TODO: Remove this if you don't want tool tips or a resizeable toolbar m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); // TODO: Delete these lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_RIGHT); } return 0; } Good luck, Jonathan Craig

    C / C++ / MFC

  • Print CRichEditCtrl from CView
    J jschacker

    I have done this with a CView derived child (CScrollView) but not with a CWnd derived child. With the CView child the code looked like this: void CViewClass::OnPrint(CDC* pDC, CPrintInfo* pInfo) { //Resize the child if needed. m_child.MoveWindow(&m_rectChild, TRUE); //Print the child. m_child.OnPrint(pDC, pInfo); //Call the base class. CView::OnPrint(pDC, pInfo); } Now the CWnd child does not have the OnPrint(...) method. But you may be able to use the CWnd::Print(CDC* pDC, DWORD dwFlags) method instead. Please let me know if it works... Jonathan Craig

    C / C++ / MFC

  • Replacement funtion for GetDIBits()-Please Help
    J jschacker

    I found the article, "A DIBSection wrapper for Win32 and WinCE", at http://codeguru.earthweb.com/ce/DIBSectionCE.shtml It may help with DIBs under Windows CE. gl Jonathan Craig

    C / C++ / MFC

  • VB / VC++ question
    J jschacker

    There is a Micosoft System Journal article that talks about this very thing. I tried the example code and it worked. I also wrote a few DLL with Visual C++ (following the steps in the article) and they worked fine with Visual Basic. You can find the article at: http://www.asia.microsoft.com/msj/defaulttop.asp?page=/msj/0498/inthisissuefeatures0498.htm gl Jonathan Craig

    C / C++ / MFC

  • How do you use the CToolTipCtrl?
    J jschacker

    There are two MSDN documents that cover this: "How to Add Tooltips for Controls to an MFC Modal Dialog Box" (on the CD set) - and - "Tiptoe Through the ToolTips With Our All-Encompassing ToolTip Programmer's Guide" (http://msdn.microsoft.com/library/periodic/period97/S245A9.htm) Also, it is a good idea to put in an option to turn off tooltips in your dialog boxes. They can get annoying once you are familiar with using the application. Good Luck Jonathan Craig

    C / C++ / MFC

  • Printing in Document-View architecture
    J jschacker

    Here is some code I used for printing multi-page documents. It doesn't use the m_rectDraw for calculating the number of pages. It gets a printer device context from the current selected printer. Then calls GetDeviceCaps(HORZRES) and GetDeviceCaps(VERTRES) to get the printer page size. BOOL CInfoWindowView::OnPreparePrinting(CPrintInfo* pInfo) { pInfo->SetMaxPage(GetNumberOfPrintPages(pInfo)); // default preparation return DoPreparePrinting(pInfo); } WORD CInfoWindowView::GetNumberOfPrintPages(CPrintInfo* /*pInfo*/) { PRINTDLG PrtDlg; HDC hDC; //// Create a printer DC if(!AfxGetApp()->GetPrinterDeviceDefaults(&PrtDlg)) { TRACE("No default printer.\n"); // use screen DC for calculations // It's OK to do this because this CDC will not be used for any // output. hDC = ::CreateDC("display",NULL,NULL,NULL); } else { CPrintDialog dlg(FALSE); dlg.m_pd.hDevMode = PrtDlg.hDevMode; dlg.m_pd.hDevNames = PrtDlg.hDevNames; hDC = dlg.CreatePrinterDC(); } CDC* pDC = CDC::FromHandle(hDC); // This is a printer DC, so set m_bPrinting // this is necessary so CScrollView::OnPrepareDC won't modify the // ViewportOrg, and cause LPtoDP to return an inappropriate result. pDC->m_bPrinting = TRUE; //// Calculate print stuff. CFont font; CFont *pOldFont; CSize size; CInfoWindowDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); //Setup the font. font.CreatePointFont(INFO_WINDOW_FONT_SIZE, INFO_WINDOW_FONT_FACE, pDC); pOldFont = pDC->SelectObject(&font); size = pDC->GetTextExtent("X"); //// Get the printer page sizeS. LONG lHeaderHeight; LONG lFooterHeight; LONG lPageWidth, lPageHeight; lPageWidth = pDC->GetDeviceCaps(HORZRES); lPageHeight = pDC->GetDeviceCaps(VERTRES); //Header height is 4 lines. lHeaderHeight = size.cy * 4; //Footer height is 2 lines. lFooterHeight = size.cy * 2; //Set header, page, and footer rects. m_rectPrintHeader.SetRect(0, 0, lPageWidth, lHeaderHeight); //Print area for info. m_rectPrintPage.SetRect(0, m_rectPrintHeader.bottom, lPageWidth, m_rectPrintHeader.bottom + (lPageHeight - (lHeaderHeight + lFooterHeight))); //Footer area. m_rectPrintFooter.SetRect(0, m_rectPrintPage.bottom, lPageWidth, lPageHeight); (size.cy * 1)); //Calculate other stuff. m_wLinesPerPrinterPage = WORD(m_rectPrintPage.Height() / size.cy); m_wPrinterPages = (WORD)ceil((double)pDoc->GetNumberOfTextLines() / m_wLinesPerPrinterPage); m_wPrinterPag

    C / C++ / MFC

  • Tab Control Help
    J jschacker

    Jeff Prosise wrote an article called “Wicked Code” for MSDN Magazine on this topic. Go to http://msdn.microsoft.com/library/period00/wicked0600.htm to see it.

    C / C++ / MFC
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups