Jump to content
Sign in to follow this  
badderjet

GDI+ refresh image: very basic GDI+ question

Recommended Posts

Hi all,I've been programming analogue gauges for the past 2 years now and recently decided it was time to venture into the world of vector gauges.I downloaded Fred Clausens sample source and after some frustrating hours getting his code to work in MSVC6++ (had to add an include and redefine the ULONG_PTR variable) I was finally able to create a working gauge. i tried to make something very simple: an Ellipse that grows bigger and smaller based on Engine1 N1 (I created a local variable containing N1):case PANEL_SERVICE_PRE_DRAW:{ PELEMENT_STATIC_IMAGE pelement = (PELEMENT_STATIC_IMAGE)(pgauge->elements_list[0]->next_element[0]); if (pelement) { HDC hdc = pelement->hdc; PIXPOINT dim = pelement->image_data.final->dim; if (hdc) { Graphics graphics(hdc); Pen pen(Color(255, 0, 0, 255)); graphics.DrawEllipse(&pen, 100, 100, (int) N1_1, (int) N1_1); } SET_OFF_SCREEN (pelement); }}break;....OK, it's very basic but like I said it's a start. Now what happens is that FS2002 (my testbed) draws an ellipse that indeed increases and descreases size with N1 but... it doesn't clean up the previous draw ! I tried adding: Color blackColor(255, 0, 0, 0); graphics.Clear(blackColor);But this paints the whole area black and no ellipse can be seen anymore.This must be very basic stuff so, can anybody help me out here ?Thx for the help,Bj


simcheck_sig_banner_devteam.jpg

 

Bj

Share this post


Link to post
Share on other sites

Where exactly did you put the redraw? Put it at the very beginning before every other drawing is done and it should clean up everything just fine upon every drawing cycle. :-)Etienne :-wave

Share this post


Link to post
Share on other sites

Etienne,Belief it or not but it just dawned on me a few minutes ago that I was indeed clearing at the end of the drawing proces :-eek Man, my brain must have been damaged somewhere along the way...Thx for the help,Bj


simcheck_sig_banner_devteam.jpg

 

Bj

Share this post


Link to post
Share on other sites

I placed the Clear method in front of the drawing method and still nothing but a black canvas... strange !Bj


simcheck_sig_banner_devteam.jpg

 

Bj

Share this post


Link to post
Share on other sites

Alright this is what happens: The gauge draws fine with the clear event first but only when I load the panel after first loading a different panel. Also when I resize the FS2002 window the drawing doesn't show until i reload the panel again.Hope this makes sense to someone...Bj


simcheck_sig_banner_devteam.jpg

 

Bj

Share this post


Link to post
Share on other sites

Well, this sounds weirdo. *:-*Where did you put your initialization stuff? Try putting it into PANEL_CONNECT_TO_WINDOW.If nothing works, either ask or feel free to shoot me an eMail or PM.Good luck though, :-hahg'niteEtienne :-wave

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...