cant paint in mFC

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

cant paint in mFC

 
0
  #1
May 22nd, 2007
  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mod7a.h"
  6.  
  7. #include "MainFrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. char file[MAX_PATH]="";
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CMainFrame
  19.  
  20. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  21.  
  22. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  23. //{{AFX_MSG_MAP(CMainFrame)
  24. ON_WM_CREATE()
  25. ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  26. ON_WM_PAINT()
  27. //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29.  
  30. static UINT indicators[] =
  31. {
  32. ID_SEPARATOR, // status line indicator
  33. ID_INDICATOR_CAPS,
  34. ID_INDICATOR_NUM,
  35. ID_INDICATOR_SCRL,
  36. };
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CMainFrame construction/destruction
  40.  
  41. CMainFrame::CMainFrame()
  42. {
  43. // TODO: add member initialization code here
  44.  
  45. }
  46.  
  47. CMainFrame::~CMainFrame()
  48. {
  49. }
  50.  
  51. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  52. {
  53. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  54. return -1;
  55.  
  56. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  57. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  58. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  59. {
  60. TRACE0("Failed to create toolbar\n");
  61. return -1; // fail to create
  62. }
  63.  
  64. if (!m_wndStatusBar.Create(this) ||
  65. !m_wndStatusBar.SetIndicators(indicators,
  66. sizeof(indicators)/sizeof(UINT)))
  67. {
  68. TRACE0("Failed to create status bar\n");
  69. return -1; // fail to create
  70. }
  71.  
  72. // TODO: Delete these three lines if you don't want the toolbar to
  73. // be dockable
  74. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  75. EnableDocking(CBRS_ALIGN_ANY);
  76. DockControlBar(&m_wndToolBar);
  77.  
  78. return 0;
  79. }
  80.  
  81. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  82. {
  83. if( !CFrameWnd::PreCreateWindow(cs) )
  84. return FALSE;
  85. // TODO: Modify the Window class or styles here by modifying
  86. // the CREATESTRUCT cs
  87.  
  88. return TRUE;
  89. }
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CMainFrame diagnostics
  93.  
  94. #ifdef _DEBUG
  95. void CMainFrame::AssertValid() const
  96. {
  97. CFrameWnd::AssertValid();
  98. }
  99.  
  100. void CMainFrame::Dump(CDumpContext& dc) const
  101. {
  102. CFrameWnd::Dump(dc);
  103. }
  104.  
  105. #endif //_DEBUG
  106.  
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CMainFrame message handlers
  109.  
  110.  
  111. void CMainFrame::OnFileOpen()
  112. {
  113.  
  114. OPENFILENAME ofn;
  115.  
  116. ZeroMemory(&ofn, sizeof(ofn));
  117. ofn.lStructSize=sizeof(OPENFILENAME);
  118. ofn.hwndOwner=NULL;
  119. ofn.lpstrFile=file;
  120. ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp";
  121. ofn.nMaxFile = MAX_PATH;
  122. ofn.Flags =OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
  123. ofn.lpstrDefExt = "bmp";
  124.  
  125.  
  126. if(GetOpenFileName(&ofn))
  127. {
  128.  
  129.  
  130.  
  131. }
  132.  
  133. }
  134.  
  135.  
  136.  
  137.  
  138.  
  139. void CMainFrame::OnPaint()
  140. {
  141. CPaintDC dc(this);
  142. RECT rec={100,100,100,100};
  143. char* c ="WHats up";
  144. dc.DrawText(c , sizeof(c), &rec ,DT_PATH_ELLIPSIS );
  145.  
  146.  
  147.  
  148. }

why cant i paint on the window on my MFC PRogram.

nothing appears just blank

can anyone help me on this pls
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,585
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1487
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: cant paint in mFC

 
0
  #2
May 22nd, 2007
Your program should probably call UpdateWindow() to force the WM_PAINT message to be put into the message queue. Have you read MSDN OnPaint description?
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: cant paint in mFC

 
0
  #3
May 22nd, 2007
il read it. but i added that updatewindow thing and still nothing
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: cant paint in mFC

 
0
  #4
May 23rd, 2007
WM_PAINT is in the message queue. but my draw text is ignored. nothing comes out of my window. maybe there are some steps i missed before drawing a text.
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: cant paint in mFC

 
0
  #5
May 23rd, 2007
i got it. hehehe
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC