Results 1 to 6 of 6

Thread: screensaver

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2000
    Location
    Ontario, Canada
    Posts
    61

    Angry

    I wish to make a screensaver that has an image bouncing around on the screen and my first problem is how do I make the form holding the image full screen
    in vb it would be:
    Code:
    form1.width = screen.width
    form1.height = screen.height
    form1.left = (screen.width - form1.width) /2
    form1.top = (screen.height - form1.height) /2
    how would I do that in VB

    second question how do get the position of the mouse
    it probably calls GetCursorPos but I do not know how to do that, I would also like to save those numbers so I can end the program when the mouse moves(and if there is an easier way to do that then please tell me)

    And how can I get an image box to bounce around the screen.
    ---~^ Absalom ^~---

    There is nobody in the world who knows everything there is no one his/her workforce who knows everything what really makes the person smart is that he/she is not affraid to ask for help.

  2. #2
    Guest
    do you know any C++ at all?


    Code:
    int x = GetSystemMetrics(SM_CXFULLSCREEN);
    int y = GetSystemMetrics(SM_CYFULLSCREEN);
    RECT r;
    GetWindowRect(hwnd, &r);
    
    SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, x - (r.left + r.right), y - (r.top + r.bottom), SWP_SHOWWINDOW);

    Code:
    POINT p;
    GetCursorPos(&p);
    int x = p.x;
    int y = p.y;

    [Edited by denniswrenn on 12-21-2000 at 10:40 PM]

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by denniswrenn

    Code:
    GetWindowRect(hwnd, *r);
    Code:
    GetCursorPos(*p);
    You need to change * to & there, Dennis...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Guest
    Sorry 'bout that... I am kinda tired today...

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2000
    Location
    Ontario, Canada
    Posts
    61
    Thanks yes I do know a little about C++

    but my strong point is VB

    But it is not as fast when it comes to speed of graFX and it is less jittery

    another question how do you change the backround color of a form

    thanks

    Merry Christmas, All
    ---~^ Absalom ^~---

    There is nobody in the world who knows everything there is no one his/her workforce who knows everything what really makes the person smart is that he/she is not affraid to ask for help.

  6. #6
    Guest
    The best way would be to set the backcolor when creating the window.

    Code:
    #include <windows.h>
    
    /* Declare Windows procedure */
    LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
    /* Make the class name into a global variable */
    char szClassName[ ] = "Whatever";
        HWND hwndp;
       
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nShowCmd)
    
    {
        MSG messages;            /* Here messages to the application are saved */
        WNDCLASSEX wincl;        /* Data structure for the windowclass */
    
        /* The Window structure */
        wincl.hInstance = hInstance;
        wincl.lpszClassName = szClassName;
        wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
        wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
        wincl.cbSize = sizeof(WNDCLASSEX);
    
        /* Use default icon and mouse-pointer */
        wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
        wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
        wincl.lpszMenuName = NULL; /* No menu */
        wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
        wincl.cbWndExtra = 0;                      /* structure or the window instance */
        /* Use light-gray as the background of the window */
        wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
    int cx = GetSystemMetrics(SM_CXFULLSCREEN);
    int cy = GetSystemMetrics(SM_CYFULLSCREEN);
    
    
        /* Register the window class, if fail quit the program */
    
        if(!RegisterClassEx(&wincl)) return 0;
    
        /* The class is registered, let's create the program*/
        hwndp = CreateWindowEx(
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Window Name",         /* Title Text */
               WS_VISIBLE | WS_MAXIMIZE, /* default window */
               0,       /* x = 0 */
               0,       /* y = 0 */
               cx,                 /* The programs width */
               cy,                 /* and height in pixels */
               HWND_DESKTOP,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               hInstance,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
               );
    
    //stuff...
    
    }
    below that is your message loop(inside winmain), and your window procedure(a whole nother function)...



    -Dennis

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