|
Hello,
I have a dialog based application and I have a custom control on it. I want to draw things in the custom control but outside of the OnPaint() function, something like:
void SomeFunc()<br />
{<br />
CPaintDC dc(this);<br />
.....<br />
......<br />
}
But this doesn't work. SO I think I've forgotten something but what ?? Any idea ?
Thanks
|
|
|
|
|
Ooops, sorry, I've forgotten to tell that the function is a member of my custom control class (of course )!
|
|
|
|
|
All drawing has to be done in OnPaint(). Any drawing done anywhere else will be erased whenever OnPaint() is called.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Yes I know, but let me explain my problem:
this custom control is in fact a 2D chart control. And I want to plot lines in it in a real-time mode (a point is plotted every 13 msec, so that's really fast). So, I don't want to redraw the complete control every time I add a point. In the OnPaint function, I draw the background (axes and grid) and I have a function (AddPoint), that draw directly on the screen with a transparent background everytime I receive a new point. The OnEraseBkgnd function has been overidden also: it does nothing.
So, OnPaint is just called when the control needs to be redrawn and in this function, I redraw also the complete lines. But this function is normally called only once at start and when, for example, a part of the control has been hidden by another window.
So, if I draw in the AddPoint function, why isn't it working? Is there a call to the OnPaint function ???
Thanks
|
|
|
|
|
cedric moonen wrote:
Is there a call to the OnPaint function ???
Add a line MessageBeep(1); at the start of OnPaint() and you will get a beep every time OnPaint() is called.
I took a closer look at your problem, and I believe it stems from your using CPaintDC. You should be using CClientDC instead. CPaintDC should only be used in OnPaint().
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks a lot !!
That works fine with CClientDC
This solves a lot of problems !
|
|
|
|
|
Glad I could help
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
i derived a dialog class named "CDlgBase" from CDialog,and then derived a
dialog class named "CDlgLogon" from "CDlgBase".
When i use the following to show CDlgLogon,the dialog showed on the screen is
CDlgBase instead of CDlgLogon. What' wrong with the code?
.....
CDlgLogon dlg;
dlg.DoModal();
.....
gucy
|
|
|
|
|
in the CDlgLogon class constructor, are you passing the dialog template ID to the CDlgBase class constructor so that it can pass it on to CDialog? I think not!
CDlgBase::CDlgBase (UINT IDD, CWnd* pParent)
: CDialog (IDD, pParent)
{
...
}
CDlgLogon::CDlgLogon(CWnd* pParent)
: CDlgBase(CDlgLogon::IDD, pParent)
{
...
}
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
yes.i does not.
and thanks a lot!
gucy
|
|
|
|
|
You are greate! This is commom error for beiginners
|
|
|
|
|
Hi,
In a dialog-based application, i have a menu, a toolbar and also in order to accelerate the process i make some keyboard functions by using PreTranslateMessage. I used the Keys from F2 to F12.
The keys worked just fine except for the F10.
I note that when the key F10 is pushied the menu also show push a little at the top-left menu title, but it don't implement my expected command.
Here is the PreTrans function i used.
BOOL CEfmraDlg::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message)
{
if(pMsg->hwnd = m_ListBox.m_hWnd)
{
case WM_KEYDOWN:
{
switch((WORD)pMsg->wParam)
{
case 'n':
case 'N':
{
m_updown = 1;
m_spinValue.SetPos(m_spinValue.GetPos()+1);
return TRUE;
}
case 'p':
case 'P':
{
if(m_secNum <= 0)
return FALSE;
else{
m_updown = 0;
m_spinValue.SetPos(m_spinValue.GetPos()-1);
return TRUE;
}
}
case VK_F2:
{
OnEfmLamp();
return TRUE;
}
case VK_F3:
{
OnEfmRead();
return TRUE;
}
case VK_F4:
{
OnEfmAbort();
return TRUE;
}
case VK_F5:
{
OnTocInfoFile();
return TRUE;
}
case VK_F6:
{
OnTocInfoCD();
return TRUE;
}
case VK_F7:
{
OnEfmCode();
return TRUE;
}
case VK_F8:
{
OnBinaryCode();
return TRUE;
}
case VK_F9:
{
OnBlock();
return TRUE;
}
case VK_F10:
{
OnSubQ();
return TRUE;
}
case VK_F11:
{
OnSubCode();
return TRUE;
}
case VK_F12:
{
OnSubRW();
return TRUE;
}
default : break;
}
break;
}
}
}
return CResizableDialog::PreTranslateMessage(pMsg);
}
How to deal eith this?
Thanks in advance!
chen
|
|
|
|
|
I think you must try to handle a F10 key in WindowProc procedure instead PreTranslateMessage
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Try handling F10 Message in WM_SYSKEYDOWN.
Please refer MSDN WM_SYSKEYDOWN help.
Regards,
Uma Mahes
|
|
|
|
|
Hi,
Thanks a lot!
It worked by using WM_SYSKEYDOWN.
chen
|
|
|
|
|
In outlook, when you want to send a mail to more than one person.you can add the receiver's name to the edit box one by one. And when you want to remove a receiver,you can just select the receiver's name in the box and can delete the whole string insdead of delete the characters one by one.I think it is very cool because it can prevent the user from removing the reveiver by mistake.But how can i make a edit
box like this? thank you.
|
|
|
|
|
It's actually a rich edit control rather than a plain edit control.
|
|
|
|
|
I have a parent hWnd. When I EnumChildWindows I can GetWindowText on each child to find the caption. But how do I get the Class Name of the children while inside the EnumChildWindows callback?
|
|
|
|
|
GetClassName()
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Use ::GetClassName(hWnd, className, _MAX_PATH) win32 API to retrive
the name of the class.
Regards,
Uma Mahes
|
|
|
|
|
Is there a way to change the print page orientation to
landscape in a dialog mode, i e I'm not using Document-
View mode? To print I've previously used ShellExecute
method.
|
|
|
|
|
Look this code:
PRINTDLG pd;
pd.lStructSize=(DWORD)sizeof(PRINTDLG);
if(AfxGetApp()->GetPrinterDeviceDefaults(&pd))
{
DEVMODE FAR *lpDevMode=(DEVMODE FAR *)::GlobalLock(pd.hDevMode);
lpDevMode->dmOrientation = (short)(bLandscape) ? ORIENT_LANDSCAPE : DMORIENT_PORTRAIT);
pDC->ResetDC(lpDevMode);
::GlobalUnlock(pd.hDevMode);
}
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Thanks, but I get these five errors when compiling:
error C2065: 'bLandscape' : undeclared identifier
error C2065: 'ORIENT_LANDSCAPE' : undeclared identifier
error C2059: syntax error : ')'
error C2065: 'pDC' : undeclared identifier
error C2227: left of '->ResetDCA' must point to class/struct/union
Generating Code...
Error executing cl.exe.
It seems bLandscape does not exist. Where does that variable come from? I can also not find ORIENT_LANDSCAPE in MSDN.
|
|
|
|
|
I can't write a code for yours. Just it is a sample of the code and not realy code.
bLanscape is a variable which specified what you want orient. TRUE - LANSCAPE, FALSE - PORTRAIT.
DMORIENT_LANDSCAPE is constant for DEVMODE strucrure. Therefore, you must look in MSDN DEVMODE structure and not constants.
pDC is a pointer to your context of the printer.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Thanks for your reply Eugene!
However, I'm sorry I still dont get it. I'm not using Document-View mode in which I think I know how to retreive the Device Context (pDC). I'm using Dialog mode. How can you acheive this?
I also noticed you converted bLandscape to short. Why? Isn't it only the value that's assignmed dmOrientation that needs to be short?!
Finally, does this alter the settings of my default printer straight away without showing any dialog, or what happens?
Thanks again,
Joachim
|
|
|
|