Click here to Skip to main content
15,867,488 members
Articles / Mobile Apps / Windows Mobile
Tip/Trick

How To Lock Device Screen For Windows Mobile

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
7 May 2012CPOL1 min read 19.7K   3   2
Lock Device Screen ,to prevent an one working on the device

Introduction

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 

Background

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.  

Image 1 

What I mean on MS_SIPBUTTON

Image 2

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 :http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx

GetWindowLong: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633584(v=vs.85).aspx 

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)
    C++
    HWND m_SipButton=::FindWindow(L"MS_SIPBUTTON",L"MS_SIPBUTTON");
    m_SipButton=::GetWindow(m_SipButton,GW_CHILD);
    if(m_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");

    C++
    ::ShowWindow(m_SipButton,SW_SHOW);//Show sip
  2. To Find HHTaskBar Class (to Disable Any Click on main Screen)
    C++
    if(m_hWndStart)
    {
    m_startProc =(WNDPROC)::GetWindowLong(m_hWndStart,GWL_WNDPROC);
    ::SetWindowLong(m_hWndStart,GWL_WNDPROC,(LONG)StartPRoc);//sublCass
    }

    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
    C++
    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))
    			{
    				MessageBeep(0);
    				return 0;
    				/*break this message to solve all trouble issues*/
    			}
    		else
    			{
    				return CallWindowProc(m_startProc,hWnd,WM_LBUTTONDOWN,wParam,lParam);
    		}
    
    		return 0;
    		}

Default:

C++
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 

License

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


Written By
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

http://windowsmobiledn.blog.com/

Comments and Discussions

 
QuestionWindows Mobile Pin
Scarfman00122-Sep-12 1:24
Scarfman00122-Sep-12 1:24 
Questionhi Pin
jeta5457-May-12 5:11
jeta5457-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.