Click here to Skip to main content
13,597,197 members
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 6 May 2012
Licenced CPOL

How To Lock Device Screen For Windows Mobile

, 7 May 2012
Rate this:
Please Sign up or sign in to vote.
Lock Device Screen ,to prevent an one working on the device


Always we need privacy on our mobile's, so we need to prevent any one working on device also some time you need to make sure the employee now playing in device "just work in specific application" 

Not solitare ..etc 


Every object on main screen or any where like start menu and sip …etc it’s just window so what we can do to make our dream true, the answer to simple FindWindow and subclass it no more

In our case we have to find handel for main screen we can find any window by Microsoft Visual Studio Remote tools.  


What I mean on MS_SIPBUTTON

Before start 

Before we begin in this article I thought you have experince in SubClassing window, and Findwindow if not please read more about it here

FindWindow :


Using the Code

Now let's talk about how find window by M.S Function and do what we want once we got the handle

  1. To Find MS_SIPBUTTON Class  (to Disable SIP Button)
    HWND m_SipButton=::FindWindow(L"MS_SIPBUTTON",L"MS_SIPBUTTON");
    ::ShowWindow(m_SipButton,SW_HIDE);//hide sip

    We got handle for sip Class ,then simply hide it by Call ShowWindow Function.

    NOTE :you should save m_SipButton handle, because in case you to show window again just call

    HWND m_SipButton=::FindWindow(L"MS_SIPBUTTON",L"MS_SIPBUTTON");

    ::ShowWindow(m_SipButton,SW_SHOW);//Show sip
  2. To Find HHTaskBar Class (to Disable Any Click on main Screen)
    m_startProc =(WNDPROC)::GetWindowLong(m_hWndStart,GWL_WNDPROC);

    The Point from SubClass HHTaskBar it's catch All windows messages before sent it to Main Screen Window, you can read more about SubClass ,it's heart of Object Oriented 

  3. Now Lets Explain StartProc SubClassing
    static LRESULT WINAPI StartPRoc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    		switch (uMsg)
    		case WM_KEYDOWN:
    		case WM_LBUTTONDOWN:
    			POINT pt;
    			//RECT rc={0,0,210,32};//Rect For Q-VGA
    			RECT rc={0,0,440,64};//Rect For Q-VGA
    			pt.x = LOWORD(lParam);
    			pt.y = HIWORD(lParam);
    		if (PtInRect(&rc,pt))
    				return 0;
    				/*break this message to solve all trouble issues*/
    				return CallWindowProc(m_startProc,hWnd,WM_LBUTTONDOWN,wParam,lParam);
    		return 0;


return CallWindowProc(m_startProc,hWnd,uMsg,wParam,lParam);}

Above code too simple: what we do actually Catch All messages before sent it to Original proc and override WM_KEYDOWN WM_LBUTTONDOWN by enforce him to return 0 no more (I mean handle any click inside main screen) I love to make my Article As Simple As Possible 


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
Jordan Jordan
Mobile Developer with deep Experience in Handheld Device Pocket Pc, Smart Phone in Win32, MFC With more than 8 years ago."Arabizer, Hook Function, Poom, Wirless Application, and low level Application". By C++ MFC and win32

You may also be interested in...


Comments and Discussions

QuestionWindows Mobile Pin
Scarfman00122-Sep-12 1:24
memberScarfman00122-Sep-12 1:24 
Ahh, developing for Windows Mobile in C... now those were the days!
Questionhi Pin
jeta5457-May-12 5:11
memberjeta5457-May-12 5:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.180621.3 | Last Updated 7 May 2012
Article Copyright 2012 by emranallan
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid