I am using VC 6 SP2 on NT4 SP4
The following is my code, can anyone tell me what I'm forgetting to
do/doing wrong?
(I've included my code for the routine rather than just the relevant few
lines in case I've missed anything else out <g>)
CWnd *wndDlg = GetParentOwner();
RECT rect;
wndDlg->GetWindowRect(&rect);
wndDlg->SetWindowPos(NULL, 0, 0, rect.right - rect.left, rect.bottom -
rect.top + 100, SWP_NOMOVE);
CWnd *wndOKCtrl = wndDlg->GetDlgItem(IDOK);
wndOKCtrl->GetWindowRect(&rect);
wndDlg->ScreenToClient(&rect);
wndOKCtrl->SetWindowPos(NULL, rect.left, rect.top + 100, 0, 0,
SWP_NOSIZE);
CWnd *wndCancelCtrl = wndDlg->GetDlgItem(IDCANCEL);
wndCancelCtrl->GetWindowRect(&rect);
wndDlg->ScreenToClient(&rect);
wndCancelCtrl->SetWindowPos(NULL, rect.left, rect.top + 100, 0, 0,
SWP_NOSIZE);
CButton Button1;
CRect ButtonRect;
ButtonRect.top = 80;
ButtonRect.bottom = 200;
ButtonRect.left = 80;
ButtonRect.right = 200;
if (Button1.Create("", BS_OWNERDRAW | BS_PUSHBUTTON | WS_VISIBLE |
WS_CHILD | WS_TABSTOP, ButtonRect, wndDlg, 1234) !=
0)
{
m_bitmapTemaC.LoadBitmap(IDB_TEMAC_BITMAP);
HBITMAP hpic = (HBITMAP) m_bitmapPic.GetSafeHandle();
((CButton *) GetDlgItem(1234))->SetBitmap(hPic);
AfxMessageBox("Success");
}
else
{
AfxMessageBox("Failure");
}
--
Malcolm Groom
--
Rick Genter
ICQ UIN# 8291497
<mailto:rgenter at vipcalling.com>
<http://www.vipcalling.com>
Malcolm Groom <Mal...@WCompSys.XXXdemon.co.uk> wrote in message
news:EWl4kAA2...@wcompsys.demon.co.uk...
Malcolm Groom a écrit :
Hello,
Sorry, but I search the same thing...
Maybe the first argument is not ok: try something like that:
- Button1.Create("BUTTON",...)
- or Button1.Create( _T("BUTTON"),...)
Thanks for help me too...
Sorry but you are mistaken, it is drawing your button, but it is drawning
NOTHING.
You told MFC to: BS_OWNERDRAW
Making it look for a function called DrawItem (a virtual function, which
should have ASSERTED because I am sure you haven't created such a function),
and when it "finds" this funtion it executes it, but nothing happens because
it doesn't exist, so it doesn't paint it.
If you remove this OWNERDRAW style, it should show up.
--
Thanks
Noam Rathaus
Malcolm Groom <Mal...@WCompSys.XXXdemon.co.uk> wrote in message
news:EWl4kAA2...@wcompsys.demon.co.uk...
> I am trying to dynamically add some buttons to a dialog I have in the
> OnInitDialog. Whilst the create is returning a success value nothing is
> appearing one the dialog apart from those buttons designed with the
> resource editor.
>
> I am using VC 6 SP2 on NT4 SP4
>
> The following is my code, can anyone tell me what I'm forgetting to
> do/doing wrong?
>
> (I've included my code for the routine rather than just the relevant few
> lines in case I've missed anything else out <g>)
>
>
> --
> Malcolm Groom
CDialog / CFormView :: OnShowWindow(BOOL bShow, UINT nStatus)
{
CButton Button1;
CRect ButtonRect;
ButtonRect.top = 80;
ButtonRect.bottom = 200;
ButtonRect.left = 80;
ButtonRect.right = 200;
if (Button1.Create("", BS_OWNERDRAW | BS_PUSHBUTTON | WS_VISIBLE |
WS_CHILD | WS_TABSTOP, ButtonRect, wndDlg, 1234) !=
0)
{
m_bitmapTemaC.LoadBitmap(IDB_TEMAC_BITMAP);
HBITMAP hpic = (HBITMAP) m_bitmapPic.GetSafeHandle();
((CButton *) GetDlgItem(1234))->SetBitmap(hPic);
AfxMessageBox("Success");
}
else
{
AfxMessageBox("Failure");
}
}
I hope this will work for u.
-Vikas
Malcolm Groom wrote:
> I am trying to dynamically add some buttons to a dialog I have in the
> OnInitDialog. Whilst the create is returning a success value nothing is
> appearing one the dialog apart from those buttons designed with the
> resource editor.
>
> I am using VC 6 SP2 on NT4 SP4
>
> The following is my code, can anyone tell me what I'm forgetting to
> do/doing wrong?
>
> (I've included my code for the routine rather than just the relevant few
> lines in case I've missed anything else out <g>)
>
Yep, I sussed it this morning after going through the other suggestions
people gave me. One of those where you slap yourself for not spotting
the obvious <g>. The OWNERDRAW caused problems too but as I wanted a
bitmap on it...
Anyway, having pointers to CButton with global dialog scope solved it.
Then changing to CBitmapButton got around the ownerdraw problem.
Thanks to everybody who made suggestions.
--
Malcolm Groom
Ken
Vikas Gupta <vgu...@rtp-bosch.com> wrote in message
news:37274EAB...@rtp-bosch.com...
On Wed, 28 Apr 1999 19:47:48 +0200, "Noam Rathaus"
<no...@radiotel.co.il> wrote:
>Hi,
>
>Sorry but you are mistaken, it is drawing your button, but it is drawning
>NOTHING.
>
>You told MFC to: BS_OWNERDRAW
>
>Making it look for a function called DrawItem (a virtual function, which
>should have ASSERTED because I am sure you haven't created such a function),
>and when it "finds" this funtion it executes it, but nothing happens because
>it doesn't exist, so it doesn't paint it.
>
>If you remove this OWNERDRAW style, it should show up.
Joseph M. Newcomer
newc...@flounder.com
http://www3.pgh.net/~newcomer
On Fri, 30 Apr 1999 07:29:33 -0400, "Ken Vadella" <k...@altair.com>
wrote:
Joseph M. Newcomer
newc...@flounder.com
http://www3.pgh.net/~newcomer
Been a while since I looked at this now. But it was definitely in the
debug version and no assert was issued. I can't remember everything I
tried before I got it working but I did manage some quite impressive
crashes before I finished :)
--
Malcolm Groom