StretchBlt problem, New APIs for windows 8, etc.

I am creating a desktop utility application in VC++ 6 using MFC.
Following are few questions:

1) I have a bitmap as a resource of dimensions 3600x2250 in 24-bit bmp true colour format.
But the screen size of my computer is 1366x768. So I decided to use StretchBlt member function. Although it seems to work quite fine, the function displays the bitmap in 256 colour format.
The BitBlt function works well with 24-bit bmp
Is there a fault in the code or the function itself works with 256 colour format?

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void OnLButtonDown(UINT hittest,CPoint pt)
{
	CWindowDC dc(this);
	CBitmap image;
	image.LoadBitmap(103);
	CDC dcMem;
	HBITMAP bitp;
	dcMem.CreateCompatibleDC(&dc);
	bitp = (HBITMAP)dcMem.SelectObject(image);
	//dc.BitBlt(0,0,screenx,screeny,&dcMem,0,0,SRCCOPY);
	dc.StretchBlt(0,0,screenx,screeny,&dcMem,0,0,3600,2250,SRCCOPY);
	//dcMem.SelectObject(bitp);
	//Beep(500,1000);
}


2) Are there are any new event handlers in Windows 8 for touch enabled displays like "OnTouch" analogous to "OnClick". Or does the OS itself convert it the "touch" event to a "click" event?

3) Is there any way I can convert a .jpg file specified by the user to .bmp file using command line? (I want it for the home screen of the aplication)
Last edited on
You can convert .jpg to .bmp using GDI+ directly in your application.
http://www.tejashwi.com/asknshare/12/converting-jpg-to-bmp-in-c
1) Try calling SetStretchBltMode() first:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd145089%28v=vs.85%29.aspx

2) I don't know about MFC, but there is a WM_TOUCH message. This might be helpful for you:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd562197%28v=vs.85%29.aspx
I also want to intercept the Alt-Tab keys to prevent task switching. I tried using RegisterHotKey() with VK_TAB and MOD_ALT. But to no avail. I cant figure out what to do after registering the hot key. Please help
You need a keyboard hook to intercept Alt + Tab, but before you try this, is it really needed ? Personally I would not use applications like this :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
LRESULT CALLBACK LowLevelKeyboardProc(INT nCode, WPARAM wParam, LPARAM lParam)
    {
        static BOOL fShiftPressed = FALSE;

        BOOL fHandled = FALSE;

        if (nCode == HC_ACTION)
        {
            KBDLLHOOKSTRUCT *pkbdllhook = (KBDLLHOOKSTRUCT *)lParam;

            switch (wParam)
            {
                case WM_SYSKEYDOWN:
                    switch (pkbdllhook->vkCode)
                    {
                        case VK_LSHIFT:
                        case VK_RSHIFT:
                        {
                            // the user pressed the shift key
                            fShiftPressed = TRUE;
                            break;
                        }
                        case VK_TAB:
                        {
                            if (pkbdllhook->flags & LLKHF_ALTDOWN)
                            {
                                // the user pressed Alt+Tab, execute AltTab hotkey handler
                                fHandled = TRUE;
                            }
                            break;
                        }
                        case VK_ESCAPE:
                        {
                            if (pkbdllhook->flags & LLKHF_ALTDOWN)
                            {
                                // the user pressed Escape, end the AltTab container
                                // window without switching the selected window
                                fHandled = TRUE;
                            }
                            break;
                        }
                    }

                    break;

                case WM_KEYUP:
                case WM_SYSKEYUP:
                    switch (pkbdllhook->vkCode)
                    {
                        case VK_LMENU:
                        case VK_RMENU:
                        {
                            // the user let go of the Alt key, end the AltTab container
                            // window switching to the selected window
                            break;
                        }
                        case VK_LSHIFT:
                        case VK_RSHIFT:
                        {
                            // the user released the shift key
                            fShiftPressed = FALSE;
                            break;
                        }
                    }

                    break;
            }
        }
        return (fHandled ? TRUE : CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam));
    }

         
         
    LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
        {
            switch( uMsg )
            {
               case WM_ACTIVATEAPP:
                    // g_bWindowActive is used to control if the Windows key is filtered by the keyboard hook or not.
                    if( wParam == TRUE )
                        YƶneticiMod  = true;          
                    else
                        YƶneticiMod  = false;          
                    break;
            }
            return false;
        }
Topic archived. No new replies allowed.