Re: [Dev-C++] Questions on WS_TABSTOP, WS_DISABLED and BitBlt
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
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
|