If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.
Special Thanks To:
Aaron Holmes
Aaron Wheeler
Adam Horden
Alan Scrimgeour
Andre
Andrew Haynes
Anonymous000
asabase
Austin Weil
barney
Barry
Bert Hickman
Bill Kukowski
Blitzorn
Brandon Paradelas
Bruce Bowling
BubeeMike
Byong Park
Cesiumsponge
Chris F.
Chris Hooper
Corey Worthington
Derek Woodroffe
Dalus
Dan Strother
Daniel Davis
Daniel Uhrenholt
datasheetarchive
Dave Billington
Dave Marshall
David F.
Dennis Rogers
drelectrix
Dr. John Gudenas
Dr. Spark
E.TexasTesla
eastvoltresearch
Eirik Taylor
Erik Dyakov
Erlend^SE
Finn Hammer
Firebug24k
GalliumMan
Gary Peterson
George Slade
GhostNull
Gordon Mcknight
Graham Armitage
Grant
GreySoul
Henry H
IamSmooth
In memory of Leo Powning
Jacob Cash
James Howells
James Pawson
Jeff Greenfield
Jeff Thomas
Jesse Frost
Jim Mitchell
jlr134
Joe Mastroianni
John Forcina
John Oberg
John Willcutt
Jon Newcomb
klugesmith
Leslie Wright
Lutz Hoffman
Mads Barnkob
Martin King
Mats Karlsson
Matt Gibson
Matthew Guidry
mbd
Michael D'Angelo
Mikkel
mileswaldron
mister_rf
Neil Foster
Nick de Smith
Nick Soroka
nicklenorp
Nik
Norman Stanley
Patrick Coleman
Paul Brodie
Paul Jordan
Paul Montgomery
Ped
Peter Krogen
Peter Terren
PhilGood
Richard Feldman
Robert Bush
Royce Bailey
Scott Fusare
Scott Newman
smiffy
Stella
Steven Busic
Steve Conner
Steve Jones
Steve Ward
Sulaiman
Thomas Coyle
Thomas A. Wallace
Thomas W
Timo
Torch
Ulf Jonsson
vasil
Vaxian
vladi mazzilli
wastehl
Weston
William Kim
William N.
William Stehl
Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Registered Member #1143
Joined: Sun Nov 25 2007, 04:55PM
Location: Vilnius, Lithuania
Posts: 721
Hello, does any one here know more about windows application programming ? I am making multi-threaded fractal painting problem, all hard job is done, all is left is fractal painting in window as fast as i can.
I have function which handles my window, but i don't know how to pass message so it will be update each time every time. ( i want to make something like animation, zooming into Julia set or other fractal)
The short answer is to use a timer and process WM_TIMER messages. And, don't bother repainting on anything else then WM_PAIN and use invalidaterect when you decide you want something repainted.
Long answer you need to use a custom message loop using PeekMessage instead of GetMessage. This is non blocking and it will allow you to draw the animation while not processing messages. But the draw function better be fast.
Registered Member #1143
Joined: Sun Nov 25 2007, 04:55PM
Location: Vilnius, Lithuania
Posts: 721
Daedronus wrote ...
The short answer is to use a timer and process WM_TIMER messages. And, don't bother repainting on anything else then WM_PAIN and use invalidaterect when you decide you want something repainted.
Long answer you need to use a custom message loop using PeekMessage instead of GetMessage. This is non blocking and it will allow you to draw the animation while not processing messages. But the draw function better be fast.
WT_timer don't do anything, or i don't wait long enough. do you know syntax how to send message to winpros function, since i can update window when i finish calculation. Glad to see that some one understands this stuff, since i am quite new in here
You need to set-up a time before you receive WM_TIMER events
Use PostThreadMessage to send a windows message to the message loop from another thread.
If you want a custom message ID, use any value like this: WM_USER+x, for example: #define WM_MY_CUSTOM_WND_MESSAGE (WM_USER +1) #define WM_MY_SECOND_CUSTOM_WND_MESSAGE (WM_USER +2)
Registered Member #1143
Joined: Sun Nov 25 2007, 04:55PM
Location: Vilnius, Lithuania
Posts: 721
Daedronus wrote ...
You need to set-up a time before you receive WM_TIMER events
Use PostThreadMessage to send a windows message to the message loop from another thread.
If you want a custom message ID, use any value like this: WM_USER+x, for example: #define WM_MY_CUSTOM_WND_MESSAGE (WM_USER +1) #define WM_MY_SECOND_CUSTOM_WND_MESSAGE (WM_USER +2)
I set up timer, but it looks i have wrong timer identifier, i set to 0,5s intervals, but it do nothing. (used random number for it, 101) about custom message, i know how to create one, i just don't know how to send it, so it will be processed by switch (ii don't know syntax for it) i can calculate fractal in 66fps, and BitBlt() works quite fast for painting, so it should looks like animation, if only i know how to send custom message :( )
if i set messages.message= WM_MY_SECOND_CUSTOM_WND_MESSAGE; in main loop for message dispatching, it paint it only one time, and i can't turn it off, since i jam message sending in my opinion, i need to use if() to check if message is quit
Registered Member #1143
Joined: Sun Nov 25 2007, 04:55PM
Location: Vilnius, Lithuania
Posts: 721
Daedronus wrote ...
If you can do 66fps you should use what is explained here: Even if it's not DirectX related, the message handling is similar.
Thanks for the link, find some usefull info aout some parts of my program. But rapid painting is the flaw. I did experiment, simply generating fractal in main, and painting as bmp without any window, and it paints single picture, than hangs and do nothing, and at same second get message from windows that my app is stopped working. So my approach it total flaw for painting code looks like this:
zoom*=2;
sideJob2(0,0,400,400); //refill matrix with new zoom
HBITMAP cross = (HBITMAP)CreateBitmap( 401, 400, 1,32,wBits); // make bmp from matrix
SelectObject(hdc, cross);
HDC hdc_x = GetDC(HWND_DESKTOP);
BitBlt(hdc_x,100,100,400,400,hdc,0,0,SRCCOPY); //paint bmp
ReleaseDC(HWND_DESKTOP,hdc_x);
can some know better idea how to do this ?
Here is what i did so far, if you take the bottom edge with mouse and try to resize, (holding bottom edge of window, and collapsing upwards, and then expand again) you will see that fractal is repainted , but not all, just that part which was covered. ]program.zip[/file] if some one is interested i can give source file
one thing you should know about SelectObject It returns the previously selected object, you have to save this and select it back when you are done, or you will have a memory/object leak. GDI objects are global resources and if you consume them windows in general (not just your application) will start to misbehave.
If you don't mind post the code here, someone might be able to provide more help.
void sideJob2(void) { long h=0; double long x,xx,y,cx,cy; int i=0; double long offset_xx= 1.5827773825793396;//+0.000181L; double long offset_yy= 0.0000000181;// 0.000000000000181L; for(int hy=0;hy<=400;hy++) { for(int hx=0;hx<=400;hx++) { cx = (((double long)hx)/((double long)400)-0.5)/zoom;//*3.0-0.7; cy = (((double long)hy)/((double long)400)-0.5)/zoom;//*3.0; cx -=offset_xx; cy -=offset_yy; x = 0.0; y = 0.0; for(i=1;i<256;i++) { xx = x*x-y*y+cx; y = 2.0*x*y+cy; x = xx; if (x*x+y*y>100.0) break; } wBits[h]=D3DCOLOR_ARGB(128,12*i,18*i,10*i); h++; } } }
UINT msg; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
sideJob2(); /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ UINT uResult; /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX);
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 Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; uResult=SetTimer(hwnd,101,1000, (TIMERPROC) NULL);
hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ L"Julia Set Fraktalų skaiÄiavimas", WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 400, /* The programs width */ 400, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); ShowWindow (hwnd, nFunsterStil);
while(TRUE) { // Check to see if any messages are waiting in the queue while(PeekMessage(&messages, NULL, 0, 0, PM_REMOVE)) { // translate keystroke messages into the right format TranslateMessage(&messages); // send the message to the WindowProc function DispatchMessage(&messages); } if(messages.message == WM_QUIT) break;
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.