Thread: [Dev-C++] Questions on WS_TABSTOP, WS_DISABLED and BitBlt
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Lucas K. T. <lk...@bo...> - 2003-02-16 14:43:13
|
Ok, first of all, I'm using WinXP and for some reason when I define controls
with the WS_TABSTOP style they should receive tab input to lose/gain focus,
right? but for some reason, then don't! eheheh btw, I'm creating those
controls with WS_VISIBLE and WS_CHILD within the WS_CREATE message handler.
As for disabling a button, I've tried using WS_ENABLE with FALSE and then
turning it back on, but that way, the control simply gets grayed, but not
disabled, but then if I add the WS_DISABLED style flag it doesn't seem to be
writeable at all, I was wondering if there was any way around this, without
having to call SetWindowLong.
And last: I'm trying to make a game, and I create a static control with
WS_CHILD | WS_VISIBLE| SS_OWNERDRAW | SS_NOTIFY styles.... then I used this
as a handler for WM_DRAWITEM:
case WM_DRAWITEM:
HBITMAP hBoardBmp, hOldBmp;
HDC hBoardDC;
LPDRAWITEMSTRUCT lpdis;
hBoardDC = CreateCompatibleDC(lpdis->hDC);
hBoardBmp = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(RSBORD));
hOldBmp = (HBITMAP)SelectObject(hBoardDC, hBoardBmp);
if (!BitBlt(lpdis->hDC, 0, 0, 93, 93, hBoardDC, 0, 0, SRCCOPY))
{
char a[50];
DWORD er;
er = GetLastError();
wsprintf(a, "%lu", er);
MessageBox(hWnd, a, NULL, 0);
}
SelectObject(hBoardDC, hOldBmp);
DeleteObject(hBoardBmp);
DeleteObject(hOldBmp);
DeleteDC(hBoardDC);
break;
Anyway, after some time trying to debug it, I found out BitBlt was giving me
an error code 6, then I went to dos prompt and typed 'net help 6' and 'net
helpmsg 6" both give me error message, so Ican't really figure out what's
going on, anyone's got any idea what error code 6 is? and/or how do I fix
this?
Note: The LoadBitmap call is working perfectly, it has no errors... I've
checked the only faulty one is BitBlt or perhaps SelectObject which I
couldn't really check.
Thanks for any answers...
lkt153
|
|
From: <or...@vp...> - 2003-02-16 21:53:36
|
Hello!
Lucas K. Tavares wrote:
> Ok, first of all, I'm using WinXP and for some reason when I define controls
> with the WS_TABSTOP style they should receive tab input to lose/gain focus,
> right? but for some reason, then don't!
Hmm..., strange problem I encountered a long time ago. If your window,
where the controls are is not a dialog box, but it is created with
CreateWindow(), then you should create it with CreateWindowEx() and
specify the first argument (dwExStyle) with WS_EX_CONTROLPARENT. Look in
the docs (Win32 API reference) for details on this.
> As for disabling a button, I've tried using WS_ENABLE with FALSE and then
> turning it back on, but that way, the control simply gets grayed, but not
> disabled, but then if I add the WS_DISABLED style flag it doesn't seem to be
> writeable at all, I was wondering if there was any way around this, without
> having to call SetWindowLong.
Use EnableWindow(hButton,FALSE) to disable and
EnableWindow(hButton,TRUE) to enable the button.
> And last: I'm trying to make a game, and I create a static control with
> WS_CHILD | WS_VISIBLE| SS_OWNERDRAW | SS_NOTIFY styles.... then I used this
> as a handler for WM_DRAWITEM:
>
> case WM_DRAWITEM:
> HBITMAP hBoardBmp, hOldBmp;
> HDC hBoardDC;
> LPDRAWITEMSTRUCT lpdis;
lpdis is in lParam. So you probably need this here:
lpdis = (LPDRAWITEMSTRUCT)lParam;
> hBoardDC = CreateCompatibleDC(lpdis->hDC);
> hBoardBmp = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(RSBORD));
> hOldBmp = (HBITMAP)SelectObject(hBoardDC, hBoardBmp);
> if (!BitBlt(lpdis->hDC, 0, 0, 93, 93, hBoardDC, 0, 0, SRCCOPY))
Are you sure, it is 93*93? You should use the lpdis->rcItem rectangle,
which specifies the boundaries of the control.
> {
> char a[50];
> DWORD er;
> er = GetLastError();
> wsprintf(a, "%lu", er);
> MessageBox(hWnd, a, NULL, 0);
> }
> SelectObject(hBoardDC, hOldBmp);
> DeleteObject(hBoardBmp);
This is not needed:
> DeleteObject(hOldBmp);
The old bitmap was not created by you.
> DeleteDC(hBoardDC);
> break;
Hope I could help.
--
Greetings,
Balázs
|
|
From: Lucas K. T. <lk...@bo...> - 2003-02-16 23:06:12
|
Thanks for everything...
I'm still in trouble with the TAB thing... I added WS_EX_CONTROLPARENT to
the parent window, but I don't know, for some reason it still won't go, I
haven't tested yet the disabling thing, I used to use
SendDlgItemMessage(blah, blah, WM_ENABLE, ...)
but it didn't work properly, wouldn't ti be the same?
and thanks the BitBlt is now working, stupid me, it was a momentary lapse=
,
thanks...
lkt153
----- Original Message -----
From: "OROSZI Bal=E1zs" <or...@vp...>
To: <dev...@li...>
Sent: Sunday, February 16, 2003 6:54 PM
Subject: Re: [Dev-C++] Questions on WS_TABSTOP, WS_DISABLED and BitBlt
> Hello!
>
> Lucas K. Tavares wrote:
> > Ok, first of all, I'm using WinXP and for some reason when I define
controls
> > with the WS_TABSTOP style they should receive tab input to lose/gain
focus,
> > right? but for some reason, then don't!
> Hmm..., strange problem I encountered a long time ago. If your window,
> where the controls are is not a dialog box, but it is created with
> CreateWindow(), then you should create it with CreateWindowEx() and
> specify the first argument (dwExStyle) with WS_EX_CONTROLPARENT. Look i=
n
> the docs (Win32 API reference) for details on this.
>
> > As for disabling a button, I've tried using WS_ENABLE with FALSE and
then
> > turning it back on, but that way, the control simply gets grayed, but
not
> > disabled, but then if I add the WS_DISABLED style flag it doesn't see=
m
to be
> > writeable at all, I was wondering if there was any way around this,
without
> > having to call SetWindowLong.
> Use EnableWindow(hButton,FALSE) to disable and
> EnableWindow(hButton,TRUE) to enable the button.
>
> > And last: I'm trying to make a game, and I create a static control wi=
th
> > WS_CHILD | WS_VISIBLE| SS_OWNERDRAW | SS_NOTIFY styles.... then I use=
d
this
> > as a handler for WM_DRAWITEM:
> >
> > case WM_DRAWITEM:
> > HBITMAP hBoardBmp, hOldBmp;
> > HDC hBoardDC;
> > LPDRAWITEMSTRUCT lpdis;
> lpdis is in lParam. So you probably need this here:
> lpdis =3D (LPDRAWITEMSTRUCT)lParam;
>
> > hBoardDC =3D CreateCompatibleDC(lpdis->hDC);
> > hBoardBmp =3D LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(RSBOR=
D));
> > hOldBmp =3D (HBITMAP)SelectObject(hBoardDC, hBoardBmp);
> > if (!BitBlt(lpdis->hDC, 0, 0, 93, 93, hBoardDC, 0, 0, SRCCOPY))
> Are you sure, it is 93*93? You should use the lpdis->rcItem rectangle,
> which specifies the boundaries of the control.
>
> > {
> > char a[50];
> > DWORD er;
> > er =3D GetLastError();
> > wsprintf(a, "%lu", er);
> > MessageBox(hWnd, a, NULL, 0);
> > }
> > SelectObject(hBoardDC, hOldBmp);
> > DeleteObject(hBoardBmp);
>
> This is not needed:
> > DeleteObject(hOldBmp);
> The old bitmap was not created by you.
>
> > DeleteDC(hBoardDC);
> > break;
>
> Hope I could help.
> --
> Greetings,
> Bal=E1zs
|