Aug 132012

I have been working on a OnScreenkeyboard for a while, and I wanted to use the available resources for a easy multilingual system.

In windows there are kbd**.dll-files that contain arrays of scan codes, virtual keys and characters linked to VK/SC. To avoid inventing the wheel again, I tried to use these.

My developer computer is a Win7-x64, and I have a VM running WinXP (32-bit) on it.
I created a 32-bit application, with default MFC-configuration.
I noticed that the pVkToWcharTable is NULL on the 64-bit machine and not NULL on the 32-bit machine after running the init KbdLayerDescriptor(). This occurred even if they loaded the same 32-bit-dll.

I tried several solutions, but all of them required to compile one 32-bit and one 64-bit version of the program. That wasn’t a satisfying solution for me, so I created a wrapper to handle such special events.

Read the article Load and init keyboard-dlls in a 64-bit enviroment (KbdLayerDescriptor), to read and download my example from the picture above.

If there are other clever souls out there who have a better way of doing it, please let me know!

 Posted by at 11:31:10
Aug 132011

After changing to Visual Studio 2010 many of my old ways of doing things didn’t work well anymore.

Recently I had a “SDI” (not really SDI since it doesn’t use the Doc/View way) that needed to be minimized @ startup.
My good old way used the ActivateFrame(int nCmdShow) and setting to SW_HIDE / SW_MINIMIZE / SW_MAXIMIZE didn’t work at all.
(The “SDI” uses the new visual styles, so I guess we don’t have full control over the ShowWindow() being called)

First in your MainFrm.h file, add this:

class CMainFrame : public CFrameWndEx
BOOL bIsHidden;

Then in the MainFrm.cpp

// CMainFrame construction/destruction
// TODO: add member initialization code here
bIsHidden = TRUE;

//This is where you block the window for showing
void CMainFrame::OnWindowPosChanging(WINDOWPOS* lpwndpos)

//When hidden we remove all the showwindow parameters (giving you the power back)
lpwndpos->flags &= ~SWP_SHOWWINDOW ;

Finally in your CWinAppEx derivated class

BOOL CAcrobatMDIishApp::InitInstance()

// The one and only window has been initialized, minimize it (or maximize it).
pFrame->ShowWindow(SW_MINIMIZE); //Comment these two out to keep the windows hidden (like a hide to systray function for instance)

It is a simple way to control the visibilty of “SDI”/”MDI” application based on the CFrameWndEx and CWinAppEx classes.

 Posted by at 22:27:14
%d bloggers like this: