CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    118

    Win2k Desktop refuse lock

    Hello, Guru, please have a look at the follwing code from "Programming Win95" . It works fine on Win95/98, but not in Win2k, please you please explain why? I have checked all handle are ok.


    #include "stdafx.h"
    #include <stdlib.h>

    #define NUM 200

    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

    int APIENTRY WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow )
    {
    static int iKeep [NUM][4] ;
    HDC hdc, hdcMem ;
    int cx, cy ;
    HBITMAP hBitmap ;
    int i, j, x1, y1, x2, y2 ;

    if (LockWindowUpdate (GetDesktopWindow ()))
    {
    hdc = CreateDC ("DISPLAY", NULL, NULL, NULL) ;
    hdcMem = CreateCompatibleDC (hdc) ;
    cx = GetSystemMetrics (SM_CXSCREEN) / 10 ;
    cy = GetSystemMetrics (SM_CYSCREEN) / 10 ;
    hBitmap = CreateCompatibleBitmap (hdc, cx, cy) ;

    SelectObject (hdcMem, hBitmap) ;

    srand ((int) GetCurrentTime ()) ;

    for (i = 0 ; i < 2 ; i++)
    for (j = 0 ; j < NUM ; j++)
    {
    if (i == 0)
    {
    iKeep [j] [0] = x1 = cx * (rand () % 10) ;
    iKeep [j] [1] = y1 = cy * (rand () % 10) ;
    iKeep [j] [2] = x2 = cx * (rand () % 10) ;
    iKeep [j] [3] = y2 = cy * (rand () % 10) ;
    }
    else
    {
    x1 = iKeep [NUM - 1 - j] [0] ;
    y1 = iKeep [NUM - 1 - j] [1] ;
    x2 = iKeep [NUM - 1 - j] [2] ;
    y2 = iKeep [NUM - 1 - j] [3] ;
    }
    BitBlt (hdcMem, 0, 0, cx, cy, hdc, x1, y1, SRCCOPY) ;
    BitBlt (hdc, x1, y1, cx, cy, hdc, x2, y2, SRCCOPY) ;
    BitBlt (hdc, x2, y2, cx, cy, hdcMem, 0, 0, SRCCOPY) ;

    Sleep (10) ;
    }

    DeleteDC (hdcMem) ;
    DeleteDC (hdc) ;
    DeleteObject (hBitmap) ;

    LockWindowUpdate (NULL) ;
    }

    return FALSE ;
    return 0;
    }








  2. #2
    Join Date
    Dec 2001
    Location
    Mumbai,India
    Posts
    159

    Re: Win2k Desktop refuse lock

    Hi,
    I think it happens because in Win2k the security policies are strict and if u have not logged in as adminstrator u don't have the previleges to lock the DeskTop.

    enjoy,
    nitin.


    Rate it if it satisfies u, because that will encourage me to give more answers.
    enjoy
    Nitin S. Jadhav

  3. #3
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    118

    Re: Win2k Desktop refuse lock

    Thanx for the reply, but I am always the admin in the local machine, the LockWindowUpdate returned TRUE(but I have to point out, it takes 5 sec in my PIII 800M machine !???). and the HDC is also valid.
    ?????


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured