Foro | | | | - Page 1 - |
| Julian Schmidt | Warum funktioniert die Mausabfrage im Hauptfenster so wie sie soll und im Nebenfenster erst nach Bestätigung von Enter?
Code auf Hauptfenster: KompilierenMarkierenSeparierenDEF GetDC(1) !"USER32","GetDC"
DEF CreateCompatibleDC(1) !"GDI32","CreateCompatibleDC"
DEF CreateCompatibleBitmap(3) !"GDI32","CreateCompatibleBitmap"
DEF SelectObject(2) !"GDI32","SelectObject"
DEF BitBlt(9) !"GDI32","BitBlt"
DEF GetCurrentObject(2) !"GDI32","GetCurrentObject"
DEF DeleteObject(1) "GDI32","DeleteObject"
DEF DeleteDC(1) !"GDI32","DeleteDC"
DEF ReleaseDC(2) !"USER32","ReleaseDC"
proc Screenshot
Parameters xpos%,ypos%,maxX!,maxY!
declare hdc&, hmdc&
hdc& = GetDC(0)
hmdc& = CreateCompatibleDC(hdc&)
hbitmap& = CreateCompatibleBitmap(hdc&,maxX!,maxY!)
SelectObject(hmdc&, hbitmap&)
BitBlt(hmdc&, 0, 0, maxX!, maxY!, hdc&, xpos%, ypos%, $0CC0020)
hbitmap& = GetCurrentObject(hmdc&, 7)
DeleteDC(hmdc&)
ReleaseDC(0,hdc&)
endproc
declare zaehler%, xpos%, ypos%, breite%, hoehe%, mod%,hbitmap&
Windowstyle 16+64
Window 0,0-0,0
ShowMax %hwnd
SetWindowPos %hwnd=99999999,99999999
Screenshot 0,0,%MaxX,%MaxY
SetWindowPos %hwnd=0,0
DrawPic hbitmap&, 0, 0; 0
UseCursor 3
while 1
sleep 50
if iskey(27)
mod%=1
Break
Endif
if %MousePressed
zaehler%=zaehler%+1
if zaehler%=1
xpos%=%MouseX
ypos%=%MouseY
UsePen 0,2,RGB(255,0,0)
Line %MouseX,0 - %MouseX,%MaxY
Line 0,%MouseY - %MaxX,%MouseY
sleep 100
elseif zaehler%=2
breite%=%MouseX-xpos%
hoehe%=%MouseY-ypos%
UsePen 0,2,RGB(255,0,0)
Line %MouseX,0 - %MouseX,%MaxY
Line 0,%MouseY - %MaxX,%MouseY
Endif
Endif
case zaehler%=2 : Break
Endwhile
case mod%<>1 : Messagebox(Str$(xpos%)+","+Str$(ypos%)+"-"+Str$(breite%)+","+Str$(hoehe%),"",64 n>
end
Code auf Nebenfenster: KompilierenMarkierenSeparierenDEF GetDC(1) !"USER32","GetDC"
DEF CreateCompatibleDC(1) !"GDI32","CreateCompatibleDC"
DEF CreateCompatibleBitmap(3) !"GDI32","CreateCompatibleBitmap"
DEF SelectObject(2) !"GDI32","SelectObject"
DEF BitBlt(9) !"GDI32","BitBlt"
DEF GetCurrentObject(2) !"GDI32","GetCurrentObject"
DEF DeleteObject(1) "GDI32","DeleteObject"
DEF DeleteDC(1) !"GDI32","DeleteDC"
DEF ReleaseDC(2) !"USER32","ReleaseDC"
proc Screenshot
Parameters xpos%,ypos%,maxX!,maxY!
declare hdc&, hmdc&
hdc& = GetDC(0)
hmdc& = CreateCompatibleDC(hdc&)
hbitmap& = CreateCompatibleBitmap(hdc&,maxX!,maxY!)
SelectObject(hmdc&, hbitmap&)
BitBlt(hmdc&, 0, 0, maxX!, maxY!, hdc&, xpos%, ypos%, $0CC0020)
hbitmap& = GetCurrentObject(hmdc&, 7)
DeleteDC(hmdc&)
ReleaseDC(0,hdc&)
endproc
declare zaehler%, xpos%, ypos%, breite%, hoehe%, hbitmap&
Windowstyle 24
Window 100,200,500,500
CopyArea
end
Proc CopyArea
declare mod%,zaehler%,infowindow&
Windowstyle 16+64'$F0
infowindow&=Create("Window",%hwnd,"",0,0,%MaxX,%MaxY)
showwindow(infowindow&,0)
Screenshot 0,0,%MaxX,%MaxY
showwindow(infowindow&,1)
startpaint infowindow&
DrawPic hbitmap&, 0, 0; 0
EndPaint
UseCursor 3
declare xpos%,ypos%,breite%,hoehe%
while 1
waitinput
if iskey(27)
mod%=1
Break
Endif
'if %MousePressed
zaehler%=zaehler%+1
if zaehler%=1
xpos%=%MouseX
ypos%=%MouseY
startpaint infowindow&
UsePen 0,2,RGB(255,0,0)
Line %MouseX,0 - %MouseX,%MaxY
Line 0,%MouseY - %MaxX,%MouseY
EndPaint
elseif zaehler%=2
breite%=%MouseX-xpos%
hoehe%=%MouseY-ypos%
startpaint infowindow&
UsePen 0,2,RGB(255,0,0)
Line %MouseX,0 - %MouseX,%MaxY
Line 0,%MouseY - %MaxX,%MouseY
EndPaint
sleep 300
Endif
'Endif
case zaehler%=2 : Break
Endwhile
UseCursor 1
destroywindow(infowindow&)
if mod%<>1
Messagebox(Str$(xpos%)+","+Str$(ypos%)+"-"+Str$(breite%)+","+Str$(hoehe%),"",64)
Endif
EndProc
|
| | | ˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗ Webseite [...] | 01.06.2011 ▲ |
| |
| | « Dieser Beitrag wurde als Lösung gekennzeichnet. » | | | Wenn Du UserMessage wm_lButtonDown bzw. 513 hinzufügst wird WaitInput auch bei einem Linksklick auf den Dialog verlassen.
Gibt auch die User32::GetCursorPos API. |
| | | | | |
| | Julian Schmidt | Cool es funktioniert Danke IF KompilierenMarkierenSeparierenDEF GetDC(1) !"USER32","GetDC"
DEF CreateCompatibleDC(1) !"GDI32","CreateCompatibleDC"
DEF CreateCompatibleBitmap(3) !"GDI32","CreateCompatibleBitmap"
DEF SelectObject(2) !"GDI32","SelectObject"
DEF BitBlt(9) !"GDI32","BitBlt"
DEF GetCurrentObject(2) !"GDI32","GetCurrentObject"
DEF DeleteObject(1) "GDI32","DeleteObject"
DEF DeleteDC(1) !"GDI32","DeleteDC"
DEF ReleaseDC(2) !"USER32","ReleaseDC"
proc Screenshot
Parameters xpos%,ypos%,maxX!,maxY!
declare hdc&, hmdc&
hdc& = GetDC(0)
hmdc& = CreateCompatibleDC(hdc&)
hbitmap& = CreateCompatibleBitmap(hdc&,maxX!,maxY!)
SelectObject(hmdc&, hbitmap&)
BitBlt(hmdc&, 0, 0, maxX!, maxY!, hdc&, xpos%, ypos%, $0CC0020)
hbitmap& = GetCurrentObject(hmdc&, 7)
DeleteDC(hmdc&)
ReleaseDC(0,hdc&)
endproc
declare zaehler%, xpos%, ypos%, breite%, hoehe%, hbitmap&
Windowstyle 24
Window 100,200,500,500
CopyArea
end
Proc CopyArea
declare mod%,zaehler%,infowindow&
Windowstyle 16+64'$F0
UserMessages 513
infowindow&=Create("Window",%hwnd,"",0,0,%MaxX,%MaxY)
showwindow(infowindow&,0)
Screenshot 0,0,%MaxX,%MaxY
showwindow(infowindow&,1)
startpaint infowindow&
DrawPic hbitmap&, 0, 0; 0
EndPaint
UseCursor 3
declare xpos%,ypos%,breite%,hoehe%
while 1
waitinput
if iskey(27)
mod%=1
Break
Endif
if %UMessage=513
zaehler%=zaehler%+1
if zaehler%=1
xpos%=%MouseX
ypos%=%MouseY
startpaint infowindow&
UsePen 0,2,RGB(255,0,0)
Line %MouseX,0 - %MouseX,%MaxY
Line 0,%MouseY - %MaxX,%MouseY
EndPaint
sleep 100
elseif zaehler%=2
breite%=%MouseX-xpos%
hoehe%=%MouseY-ypos%
startpaint infowindow&
UsePen 0,2,RGB(255,0,0)
Line %MouseX,0 - %MouseX,%MaxY
Line 0,%MouseY - %MaxX,%MouseY
EndPaint
sleep 300
Endif
Endif
case zaehler%=2 : Break
Endwhile
UseCursor 1
destroywindow(infowindow&)
if mod%<>1
Messagebox(Str$(xpos%)+","+Str$(ypos%)+"-"+Str$(breite%)+","+Str$(hoehe%),"",64)
Endif
EndProc
|
| | | ˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗˗ Webseite [...] | 02.06.2011 ▲ |
| |
|
AnswerThemeninformationenDieses Thema hat 2 subscriber: |