PDA

Click to See Complete Forum and Search --> : screensaver


absalom
Dec 21st, 2000, 07:12 PM
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:

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.

Dec 21st, 2000, 09:02 PM
do you know any C++ at all?



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);





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



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

parksie
Dec 21st, 2000, 09:17 PM
Originally posted by denniswrenn


GetWindowRect(hwnd, *r);


GetCursorPos(*p);


You need to change * to & there, Dennis... ;)

Dec 21st, 2000, 09:40 PM
Sorry 'bout that... I am kinda tired today...

absalom
Dec 25th, 2000, 09:07 PM
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

Dec 25th, 2000, 09:27 PM
The best way would be to set the backcolor when creating the window.


#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