Can somebody tell me why?

I have a line on a map. If an editcontrol is changed I want a new line to be drawn according to the following code.
.elseif edx==EN_CHANGE 

.if eax==IDC_EDT1
invoke RedrawWindow,hMap,0,0,RDW_INVALIDATE
invoke MoveToEx,hDC,pointPOS.x,pointPOS.y,NULL
mov eax,pointPOS.x
add eax,5000
mov ecx,pointPOS.y
add ecx,0
invoke LineTo,hDC,eax,ecx
.endif
.endif

No line is drawn. But if I insert a line "invoke messagebox,0,0,0,MB_OK" anywhere between ReDrawWindow and LineTo a line is drawn. How come?

Regards
Posted on 2003-05-18 14:05:55 by minor28
RedrawWindow AFTER you've drawn line, not before.
Posted on 2003-05-18 15:00:06 by comrade
Hi comrade

If I insert these lines I can skip the first RedrawWindow and messagebox. The line is drawn.
.

.
invoke LineTo,hDC,eax,ecx
invoke GetWindowRect,hMap,addr lpRect
invoke RedrawWindow,hMap,addr lpRect,0,RDW_INVALIDATE

But now I have two lines. The first RedrawWindow was ment to erases the first line. If I put it back no line is drawn unless the messagebox line is inserted. I don't understand why.
Posted on 2003-05-18 15:30:51 by minor28
Maybe invoke RedrawWindow,hMap,addr lpRect,0,RDW_INVALIDATE|RDW_ERASE|RDW_INTERNALPAINT, and paint the line in the WM_PAINT handler?
Posted on 2003-05-19 07:16:51 by El_Choni
Hi El_Choni

The problem is not drawing the line, it's why I have to have a messagebox call to get the line. No messagebox no line.
Posted on 2003-05-20 06:47:47 by minor28

But now I have two lines. The first RedrawWindow was ment to erases the first line. If I put it back no line is drawn unless the messagebox line is inserted. I don't understand why.


where's the first RedrawWindow?

you insert a messagebox in the middle of the messageloop? i dont know how its done, but might be your msgloop have been round and round for many times meanwhile the msgbox appear. i suspect that something happen between the top window changes . try to explore in this gap.
Posted on 2003-05-20 07:05:45 by dion
At last I found out what was wrong. After several hours of trial and error I found out that I simply could put a "pushad" before RedrawWindow and a "popad" before .endif.

Now I will try to solve the problem with my round window which apparently no one is able to give me a hint on. But I never give up.

Edit:
perhaps I should put the final code here
.elseif edx==EN_CHANGE 

.if eax==IDC_EDT1
invoke GetDlgItemInt,hDlg,IDC_EDT1,0,FALSE
invoke SendDlgItemMessage,hDlg,IDC_TRB1,TBM_SETPOS,TRUE,eax
.if flGoTo==FALSE
pushad
invoke RedrawWindow,hMap,0,0,RDW_INVALIDATE
invoke MoveToEx,hDC,pointPOS.x,pointPOS.y,NULL
invoke GetDlgItemText,hDlg,IDC_EDT1,addr ShipGoTo.Course,24
invoke StrToFloat,addr ShipGoTo.Course,addr ShipGoTo.fpCourse
finit
fld ShipGoTo.fpCourse
fmul PIOver180
fsin
mov temp,5000
fmul temp
fadd pointPOS.x
fstp pointTO.x

fld ShipGoTo.fpCourse
fmul PIOver180
fcos
mov temp,5000
fmul temp
fstp pointTO.y
fld pointPOS.y
fsub pointTO.y
fstp pointTO.y
invoke LineTo,hDC,pointTO.x,pointTO.y
mov flGoTo,TRUE
popad
.endif
.endif
Posted on 2003-05-20 14:37:20 by minor28
Your having problems because your not using GDI properly.

You use the Redraw API to tell the Windows OS that you would like to see the window redrawn. Thats it. You dont then continue to draw afterwords (in this section of code). The OS is a message based system. You tell it your intentions, and walk away.

A short time later (micro seconds) the OS will renter your program with the message WM_PAINT as a result of your request. It is here in the WM_PAINT handler, using begin and end paint, that you should do all your line drawing as your doing it above.

:NaN:
Posted on 2003-05-20 22:28:38 by NaN
I suppose you are right if you work in a ordinary process. My project is an addin dll to a stand alone app.

The owner of the window is the app. The dll retrievs data from the app and do some processing. Finaly I want a graphical presentation (the line) on the window, which acctually is a map. Perhaps I can do it in another more properly way, but I don't know how. So far my way works whithout disturbance. The project is not completed yet, so my work will continue with among other things the round window. I can't understand why a round window have to be so complicated.

Regards
Posted on 2003-05-22 15:37:03 by minor28