|
Toubou wrote: BOOL res = ::UpdateLayeredWindow(m_hWnd, ::GetDC(0), 0, &s, hdc, &p, 0, &bf, ULW_ALPHA); //<-- ERROR HERE
I'm not sure though, try giving second parameter as NULL.
BOOL res = ::UpdateLayeredWindow(m_hWnd, NULL, 0, &s, hdc, &p, 0, &bf, ULW_ALPHA);
|
|
|
|
|
|
*SOLVED*
UpdateLayeredWindow() Doesn't work in Modal dialog, it works in Modeless dialog
|
|
|
|
|
hi
I am my app i am showing a form to a user using using the doModal method.
int nRet = myFrm.DoModal();
And OnOk event of this form i am validating all the fields. But the problem is , if the user presses the escape key on this dialog, the form gets closed and in nRet i get value as IDOK , without validating any feilds of the form. Why is it happening so.. and how to avoid it.
Vikram Verma
|
|
|
|
|
See the FAQ[^]
vikram Verma wrote: if the user presses the escape key on this dialog, the form gets closed and in nRet i get value as IDOK
How did you check that the return value was IDOK ? It should be IDCANCEL as far as I know.
|
|
|
|
|
yes it was IDCANCEL. I rechecked . And thanks .. I should have gone for FAQ 1st... i am C# programmer stuck due to some work in MFC.
|
|
|
|
|
vikram Verma wrote: And OnOk event of this form i am validating all the fields.
Why have an enabled OK button if fields/controls have invalid contents? That's a bit misleading, in my opinion.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Newbie00 wrote: How do you know that he has enabled ok button if the fields are filled in improperly??
Because he is validating the controls in response to the OK button being clicked. That means the OK button is enabled.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
David didn't say so... he said that the UI was badly designed if the user were allowed to validate (press ok button) invalid datas... there should be an On-Fly data validity checking to enable/disable Ok button
|
|
|
|
|
Newbie00 wrote: [Message Deleted]
message deletion is crime here!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
ThatsAlok wrote: message deletion is crime here!
|
|
|
|
|
I've deleted the message because it wasn't worth seeing. I didn't understand David's reply properly ("validating" --> now I know what it really means :]), and I wrote rubbishy post.
ThatsAlok wrote: message deletion is crime here!
Shall I burn on the balefire....
|
|
|
|
|
Newbie00 wrote: hall I burn on the balefire....
he he he
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I want to draw a small arrow bitmap on top of already drawn button. I tried with calling default drawing proc before my code for drawing bitmap but it gives me some error.
OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)<br />
{<br />
CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);<br />
<br />
HDC thdc = CreateCompatibleDC(lpDrawItemStruct->hDC);<br />
HGDIOBJ tobj = SelectObject(thdc, LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_ARROW_DOWN)));<br />
TransparentBlt(lpDrawItemStruct->hDC, lpDrawItemStruct->rcItem.right - 20, lpDrawItemStruct->rcItem.top + (lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top - 16) / 2, 16, 16, thdc, 0, 0, 16, 16, RGB(255, 0, 255));<br />
SelectObject(thdc, tobj);<br />
DeleteDC(thdc);<br />
}
if i exclude "CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);" then code works, but there is no borders and caption text, just my bitmap.
|
|
|
|
|
Igor Jerosimic wrote: but it gives me some error.
Whats the error?
After making the button owner draw, you have to draw the entire button your self. the DrawItem() function of CButton only contains Assert(FALSE); , which will result in a Abort-Retry--Ignore dialog.
nave
|
|
|
|
|
It stops on some ASSERT...
I know that i have to draw the entire button by myself, but my question is how do i let windows draw that button for me (with al it's visual styles) and i just want to draw small bitmap in right corner of button?
|
|
|
|
|
why dont u use CBitmapButton?
Another way is to handle the WM_PAINT message of the button and draw the bitmap after the default paint.For this you need to derive a class from CButton and make control variable of button of this class type.I am not sure about this technique.
eg:
void CMyBotton::OnPaint()
{
CButton::OnPaint();
// Draw the bitmap
}
nave
|
|
|
|
|
Naveen R wrote: CButton::OnPaint();
Should not call base class.
|
|
|
|
|
prasad_som wrote: Should not call base class
why?
I said him to do so in a non owner draw button.
nave
|
|
|
|
|
It doesn't have any effect there.
|
|
|
|
|
prasad_som wrote: It doesn't have any effect there.
Whats do you mean. If I didnt called the default procedure for WM_PAINT, then how will the button get painted? Nothing will appear in the place of button. Isn't it?
nave
|
|
|
|
|
Naveen R wrote: Whats do you mean. If I didnt called the default procedure for WM_PAINT, then how will the button get painted?
You are confusing between painting a control and drawing a control.
In case of of non-owner drawn control windows takes care of drawing/creating control. WM_PAINT message is meant to paint invalidated area.
Now about calling base class OnPaint . It simply does default painting routines and validates invalidated area.
So Consider this function,
void CMyButton::OnPaint()
{
CButton::OnPaint();
and code following has no effect
CPaintDC dc(this);
}
Consider another scenario,
void CMyButton::OnPaint()
{
CPaintDC dc(this);
invalidated area will be validated and
CButton::OnPaint has no effect.
CButton::OnPaint();
}
Hope this clears your doubts.
|
|
|
|
|
prasad_som wrote: void CMyButton::OnPaint(){ CButton::OnPaint();// //Here at above line invlaidated client area will be validated and code following has no effect CPaintDC dc(this); // device context for painting //drawing routine follows}
I never said to create another CPaintDC below the CButton::OnPaint(); He can use CClientDC dc(this) to create a device context and do painting to it. Surely it will work.
nave
|
|
|
|
|
I already tried something with WM_PAINT, but it didn't work. And after reading this article in MSDN i give up on WM_PAINT...
"Handling WM_PAINT
The most extreme choice is to implement a WM_PAINT handler and do all the painting yourself."
http://msdn2.microsoft.com/en-us/library/ms364048(vs.80).aspx
|
|
|
|