Ich habe unter Codeproject folgendes gefunden:
Zu dieser Anwendung gehört eine DLL, vllt kann man die unter Xprofan
nutzen.:-)
Dort gibt es noch einige interessante Demos: Painter,GDI+Generator.
Ich habe unter Codeproject folgendes gefunden:
Zu dieser Anwendung gehört eine DLL, vllt kann man die unter Xprofan
nutzen.:-)
Dort gibt es noch einige interessante Demos: Painter,GDI+Generator.
Bevor ich es vergesse,
Allen ein Frohes Osterfest ! ![]()
Wie kann man im letzten Beispiel von Andreas die Füllung
halbtransparent machen ![]()
![]()
Hallo Andreas,
$H Windows.ph
cls
Struct RECT = left&,top&,right&,bottom&
Declare Ende&,startx&,starty&
Var R# = New(RECT)
Whilenot Ende&
WaitInput
startx&=%mousex
starty&=%mousey
while %mousepressed
~SetROP2(%hdc,~R2_NOTXORPEN)
' IfNot ~IsRectEmpty(r#)
Rectangle R#.Left&,R#.Top& - R#.right&,R#.bottom&
' EndIf
~SetRect(R#,startx&,starty&,%mousex,%mousey)
Rectangle R#.Left&,R#.Top& - R#.right&,R#.bottom&
Endwhile
~SetROP2(%hdc,~R2_NOTXORPEN)
EndWhile
Alles anzeigen
So funktioniert dein Beispiel in alle Richtungen.
Das zweite Beispiel ist spitze.:-)
Danke Frank ![]()
Beispiel 1 sieht schon mal gut aus.
Das Testprogramm in C++ kriegt das nicht hin.:-)
Ich suche schon länger die Möglichkeit eine Linie,ein Rechteck mit der
Maus flimmerfrei auf den Bildschirm zu zeichnen.
Ich habe eine Lösung gefunden, deren Umsetzung in Profan mir nicht gelingt.(Text zwischen den beiden Smilies)
Zitat:
" ( wg. Guttenberg )
Echtzeit-Ausgabe beim Erstellen und Editieren von Zeichenobjekten
Wenn man zum Beispiel mit der Maus in einem Zeichenprogramm ein geometrisches Objekt (z.B. ein Polygon) auf der Zeichenfläche in Echtzeit von Position A nach Position B verschieben möchte, dann wäre es sinnlos, für jede der Zwischenpositionen, an denen sich die Maus gerade befindet, alles neu zu zeichnen, den Puffer zu füllen und anschließend auszugeben. Hier bedient man sich eines Kniffes. Mit Hilfe des ROP (Raster Operator) kann man mit XOR (exklusives OR) folgendermaßen vorgehen.
:-)Man zeichnet das zu verschiebende Objekt zunächst mit XOR an der alten Stelle noch einmal direkt auf dem Ausgabegerät. Dadurch „verschwindet“ dieses Objekt auf der Ausgabefläche wie von Geisterhand. Nun zeichnet man das Objekt direkt und ohne XOR an die neue Position, so dass es dort wieder sichtbar wird. Das wiederholt man bei jeder einzelnen Mausbewegung erneut, so dass innerhalb einer Sekunde durchaus 10-50 Positionsveränderungen dargestellt werden können. Das träge Auge nimmt dies als ruckelfreien und fließenden Vorgang ohne Flimmern wahr.:-) Erst am Schluss wird der Puffer komplett neu gefüllt und ausgegeben. Diese Methode des nicht beständigen, direkten Zeichnens auf ein Device nennt man auch „floating drawing“.
"
Bei Microsoft findet man folgendes:
For a color device, GDI uses RGB values to represent the colors of the pen and the destination. An RGB color value is a long integer that contains a red, a green, and a blue color field, each specifying the intensity of the specified color. Intensities range from 0 through 255. The values are packed in the three low-order bytes of the long integer. The color of a pen is always a solid color, but the color of the destination may be a mixture of any two or three colors. If an application attempts to draw with a white pen on a blue destination by using the available binary raster operations, the following results occur.
Raster operation Result
R2_BLACK Visible black line
R2_COPYPEN Visible white line
R2_MASKNOTPEN Visible black line
R2_MASKPEN Invisible blue line
R2_MASKPENNOT Visible red/green line
R2_MERGENOTPEN Invisible blue line
R2_MERGEPEN Visible white line
R2_MERGEPENNOT Visible white line
R2_NOP Invisible blue line
R2_NOT Visible red/green line
R2_NOTCOPYPEN Visible black line
R2_NOTMASKPEN Visible red/green line
R2_NOTMERGEPEN Visible black line
R2_NOTXORPEN Invisible blue line
R2_WHITE Visible white line
R2_XORPEN Visible red/green line
Kann mir jemand ein Beispiel machen, indem diese GDI32 Funktionen
(Rasteroperationen XOR) benutzt werden.![]()
![]()
Hallo Volkmar,
ich hätte es nicht besser sagen können.;)
Mit dem gleichen Code eine Groupbox mit blauem Text ! und orangenem
Hintergrund und ohne BS_Autoradiobutton ????![]()
[Blockierte Grafik: http://s3.postimage.org/1dgthzs5g/group.jpg]
Hier das Ergebnis mit $09;)
[Blockierte Grafik: http://s2.postimage.org/250bi4d5w/image.jpg]
Hallo Volkmar,
so ganz hab ich deinen Kommentar nicht verstanden.:-)
BS_AUTORADIOBUTTON = $09
$A = $09 | $01
Wenn ich nur $09 setze bekomme ich einen anderen Buttontyp.
Du kannst ja mal den letzten Wert von 1 bis A durchlaufen.
Das Beispiel erzeugt bei mir ein Rechteck in der vorgegebenen Farbe.
Wenn man draufklickt und die Maustaste links festhält, erscheint ein
Button in grau.(win xp mit allen SP,xprofan 11.2)
Gibt es einen Gdi Befehl, der dieses Grau ändert ?
Wenn ich den engl. Text richtig verstehe , soll das ganze ohne
ownerdrawstyle funktionieren ?
Ich will niemanden belehren, ich versuche für mich ein paar Dinge zu
verstehen.:-)
aus MSDN :
WM_CTLCOLORBTN bug
WM_CTLCOLORBTN does not perform as intended on Windows XP SP2/SP3 (and others?).
To properly change the foreground and background color of BUTTON types (and others)
Use the WM_CTLCOLORSTATIC message. You DO NOT use the BS_OWNERDRAW style!
Example code (using a BUTTON, with style BS_AUTORADIOBUTTON):
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CTLCOLORSTATIC: {
if ((HWND)lParam == filterNameOff) {
static HBRUSH hBrushColor;
if (!hBrushColor) {
hBrushColor = CreateSolidBrush(RGB(0xFF, 0xFF, 0xFF)); // White background is returned
SetBkColor((HDC)wParam, RGB(0xFF, 0xFF, 0xFF)); // White background for text
}
// Background color that is used to repaint the control (doesn't affect text background)
return (LRESULT)hBrushColor;
}
}
....
Warum funktioniert dieser Code nicht ?
Set("FastMode",1)
$H windows.ph
$H messages.ph
$I C:\PRFellow\LIB\profalt.inc
Declare brush&
Def GetWindowLong(2) !"USER32","GetWindowLongA"
Def SetWindowLong(3) !"USER32","SetWindowLongA"
Def SetWinPos(7) !"USER32","SetWindowPos"
Proc wSetStyle
Parameters h&,s&,x%
SetWindowLong(h&,x%,Or(GetWindowLong(h&,x%),s&))
SetWinPos(h&,0,0,0,0,0,$023)
EndProc
Proc SetWindowStyles
Parameters h&,s&,x&
WSetStyle h&,s&,-16
WSetStyle h&,x&,-20
EndProc
PROC SetColor
Parameters col&,bk&,wParam&
IF Brush&
~DeleteObject(Brush&)
Endif
Brush& = ~CreateSolidBrush(bk&)
'~SetBkMode(wParam&, ~TRANSPARENT)
~SetBkColor(wparam&, bk&)
~SetTextColor(wParam&,col&)
Return Brush&
Endproc
Proc newcallback
Parameters wnd&,msg&,wparam&,lparam&
IF msg&=~WM_CTLCOLORStatic
If lparam&=static&
Return SetColor(rgb(199,120,000),rgb(199,100,000),wParam&)
EndIf
EndIf
If msg&=~WM_CLOSE
~DeleteObject(brush&)
raus&=1
Endif
RETURN ~CallWindowProc(oldcallback&,wnd&,msg&,wparam&,lparam&)
EndProc
cls
'BS_AUTORADIOBUTTON Style setzen $09
var static&= @Control("Button", "1", $5000000A, 16,16,60,20, %hWnd,0, %hInstance)
var oldcallback&=~SetWindowLong(%hwnd,~GWL_WNDPROC,ProcAddr("newcallback",4))
Var raus&=0
WhileNot raus&
WaitInput
EndWhile
End
Alles anzeigen
Hier ist der richtige Code:D
$P+
SetErrorLevel 0
' Position von WFFORMS7.INC nicht verändern!
$I C:\PRFellow\LIB\WFFORMS7.INC
def SetWindowLong(3) !"USER32","SetWindowLongA"
def GetWindowLong(2) !"USER32","GetWindowLongA"
def SetLayeredWindowAttributes(4) !"USER32","SetLayeredWindowAttributes"
def &GWL_EXstyle -20
def &WS_EX_LAYERED $80000
Proc TransParent
Parameters element&,transcolor&,Janein&
declare Ret&
Ret&=Getwindowlong(element&,-20)
Ret&=Ret& | $80000
Setwindowlong(element&,&GWL_EXstyle,Ret&)
If janein&
SetLayeredWindowAttributes(element&,0,TransColor&,$1)
else
SetLayeredWindowAttributes(element&,0,255,$1)
endif
endproc
declare i%
' *** GlobalStatements der Form
' *** GlobalStatements der Form-Controls
Proc OnApplicationExit
EndProc
Proc OnApplicationInit
EndProc
OnApplicationInit
Declare appexit%
Declare MultiEdit1&
SetTrueColor 1
WindowStyle $003F
WindowTitle ""
Window Add(%maxX,5),114 - 498,408
Cls GetSysColor(15)
UseFont "MS Sans Serif",13,0,0,0,0
SetDialogFont 1
SetFormIcon "",0
Let MultiEdit1&=CreateMultiEdit(%hwnd,"",40,50,402,249)
ClearList
AddString "'Gallia est omnis divisa in partes tres, quarum unam incolunt '"
AddString "Belgae, aliam Aquitani, tertiam, qui ipsorum lingua Celtae, '"
AddString "nostra Galli appellantur. Hi omnes lingua, institutis, '"
AddString "legibus inter se differunt. Gallos ab Aquitanis Garunna '"
AddString "flumen, a Belgis Matrona et Sequana divit.\nHorum omnium '"
AddString "foritissimi sunt Belgae, propterea quod a cultu atque '"
AddString "humanitate provinciae longissime absunt minimeque ad eos '"
AddString "mercatores saepe commeant atque ea, quae ad effeminandos '"
AddString "animos pertinent, important proximique sunt Germanis, qui '"
AddString "trans Thenum incolunt, quibuscum continenter bellum '"
AddString "gerunt.\n\nApud Helvetios longe noblilissimus fuit et '"
AddString "ditissimus Orgetorix. Is M. Messala M. Pisone consulibus '"
AddString "regni cupiditate inductus coniurationem nobilitatis fecit '"
AddString "et civitati persuasit, ut de finibus suis cum omnibus '"
AddString "copiis exirent: perfacile esse, cum virtute omnibus '"
AddString "praestarent, totius Galliae imperio potiri.\nId hoc '"
AddString "gacilius iis persuasit, quod undique loci natura Helvetii '"
AddString "continentur: una ex parte flumine Rheno latissimo atque '"
AddString "altissimo, qui agrum Helvetium a Germanis dividit, altera '"
AddString "ex parte monte Iura altissimo, qui est inter Sequanos '"
AddString "et Helvetios, tertia lacu Lemanno et flumine Thodano, '"
AddString "qui provinciam nostram ab Helvetiis dividit.\n'"
AddString "\nG. J. Caesar';"
MoveListToEdit(MultiEdit1&)
ClearList
SetWindowPos %hwnd = 207,114 - 498,408;0
WhileNot appexit%
TransParent %hwnd,255,1
If Equ(%key,2)
Let appexit%=1
ElseIf GetFocus(MultiEdit1&)
ElseIf Equ(%key,4)
' Fenstergröße
ElseIf Equ(%key,5)
' Hilfe
EndIf
WaitInput
Wend
OnApplicationExit
Hier mal einen Code für ein transparentes Fenster.
Eigentlich nichts Spektakuläres, wenn nicht das Multiedithintergrund auch
transparent wäre. Funtkioniert bei anderen Controls nicht.
$P+
SetErrorLevel 0
' Position von WFFORMS7.INC nicht verändern!
$I C:\PRFellow\LIB\WFFORMS7.INC
def SetWindowLong(3) !"USER32","SetWindowLongA"
def GetWindowLong(2) !"USER32","GetWindowLongA"
def SetLayeredWindowAttributes(4) !"USER32","SetLayeredWindowAttributes"
def &GWL_EXstyle -20
def &WS_EX_LAYERED $80000
Proc TransParent
Parameters element&,transcolor&,Janein&
declare Ret&
Ret&=Getwindowlong(element&,-20)
Ret&=Ret& | $80000
Setwindowlong(element&,&GWL_EXstyle,Ret&)
If janein&
SetLayeredWindowAttributes(element&,0,TransColor&,$1)
else
SetLayeredWindowAttributes(element&,0,255,$1)
endif
endproc
Proc preparehdl4alpha
Parameters hdl&
SetWindowLong(hdl&, -20, @xOr(GetWindowLong(hdl&,-20),$80000));
EndProc
Proc alpha
Parameters hdl&,aval%
SetLayeredWindowAttributes(hdl&, 0, aval%, $2);
EndProc
Proc alpha2
Parameters hdl&,aval%
SetWindowLong(hdl&, -20, @Or(GetWindowLong(hdl&,-20),$80000));
SetLayeredWindowAttributes(hdl&, 0, aval%, $2);
EndProc
declare i%
' *** GlobalStatements der Form
' *** GlobalStatements der Form-Controls
Proc OnApplicationExit
EndProc
Proc OnApplicationInit
EndProc
OnApplicationInit
Declare appexit%
Declare MultiEdit1&
SetTrueColor 1
WindowStyle $003F
WindowTitle ""
Window Add(%maxX,5),114 - 498,408
Cls GetSysColor(15)
UseFont "MS Sans Serif",13,0,0,0,0
SetDialogFont 1
SetFormIcon "",0
Let MultiEdit1&=CreateMultiEdit(%hwnd,"",40,50,202,249)
ClearList
AddString "'Gallia est omnis divisa in partes tres, quarum unam incolunt '"
AddString "Belgae, aliam Aquitani, tertiam, qui ipsorum lingua Celtae, '"
AddString "nostra Galli appellantur. Hi omnes lingua, institutis, '"
AddString "legibus inter se differunt. Gallos ab Aquitanis Garunna '"
AddString "flumen, a Belgis Matrona et Sequana divit.\nHorum omnium '"
AddString "foritissimi sunt Belgae, propterea quod a cultu atque '"
AddString "humanitate provinciae longissime absunt minimeque ad eos '"
AddString "mercatores saepe commeant atque ea, quae ad effeminandos '"
AddString "animos pertinent, important proximique sunt Germanis, qui '"
AddString "trans Thenum incolunt, quibuscum continenter bellum '"
AddString "gerunt.\n\nApud Helvetios longe noblilissimus fuit et '"
AddString "ditissimus Orgetorix. Is M. Messala M. Pisone consulibus '"
AddString "regni cupiditate inductus coniurationem nobilitatis fecit '"
AddString "et civitati persuasit, ut de finibus suis cum omnibus '"
AddString "copiis exirent: perfacile esse, cum virtute omnibus '"
AddString "praestarent, totius Galliae imperio potiri.\nId hoc '"
AddString "gacilius iis persuasit, quod undique loci natura Helvetii '"
AddString "continentur: una ex parte flumine Rheno latissimo atque '"
AddString "altissimo, qui agrum Helvetium a Germanis dividit, altera '"
AddString "ex parte monte Iura altissimo, qui est inter Sequanos '"
AddString "et Helvetios, tertia lacu Lemanno et flumine Thodano, '"
AddString "qui provinciam nostram ab Helvetiis dividit.\n'"
AddString "\nG. J. Caesar';"
MoveListToEdit(MultiEdit1&)
ClearList
preparehdl4alpha %hwnd
SetWindowPos %hwnd = 207,114 - 498,408;0
WhileNot appexit%
alpha %hwnd,190
'TransParent %hwnd,100,0
If Equ(%key,2)
Let appexit%=1
ElseIf GetFocus(MultiEdit1&)
ElseIf Equ(%key,4)
' Fenstergröße
ElseIf Equ(%key,5)
' Hilfe
EndIf
WaitInput
Wend
OnApplicationExit
Ich bräuchte jetzt nur noch Tips:
- Markierung beim Edit einfärben.
- Button , Buttontext farbig
- Listbox Markierung farbig.(geht glaube ich mit Sendmessage)
Ich werde mal weiter suchen.
Beide RGB müssen gleich sein.
brush&=~CreateSolidBrush(Rgb(0,05,255))
~SetBkColor(wparam&, RGB(0, 05,255))
SetBkMode(hdc, TRANSPARENT) ist wohl der falsche Befehl.
So funktioniert es bei beiden Edittypen
Hier eine Lösung aus einem C++ - Forum:
> case WM_CTLCOLOREDIT:
> hCtrl=(HWND)lParam;
> hdc=(HDC)wParam;
> SetBkMode(hdc,TRANSPARENT);![]()
SetBkColor(hdc, RGB(0, 0,255)):-)
> SetTextColor(hdc,RGB(255,0,0));
> return (int)hBrush;
>
> where hBrush is my brush create with
> CreateSolidBrush(RGB(0,0,255));
>
> this code works perflectly if the edit control is not multiline
> (ES_MULTILINE style), otherwise I have refresh problems when the
> content is modified (you can't read no more the characters you type).
>
> If I comment the SetBkMode statement it works but when I type some
> characters the background becomes white...
If you return a valid brush handle, you should also SetBkColor to the same
color as the brush. Calling SetBkMode is not expected, and as so, the
control stops working properly.
So just replace SetBkMode(hdc, TRANSPARENT) with SetBkColor(hdc, RGB(0, 0,
255)) and you should get what you expected.
I don't know how the control would behave like in the case of a bitmap
brush. You probably would end up with the brush being used to fill the empty
space not overwritten by the BkColor generated by the text output functions
called by the Edit control.
Es ist mir auch schon aufgefallen,daß das Neuzeichnen beim Edit nicht
funktioniert.Wenn man mehrere Zeilen reinschreibt und die Scrollbar
bedient, stimmts wieder beim Multiedit.:-)
Dann gibt es vllt. auch eine Lösung fürs Neuzeichnen.
Es geht mir darum eine Einfärbmethode für möglichst viele Controls
zu haben.;)
[Blockierte Grafik: http://s4.postimage.org/26dprukh0/Callback.jpg]
Danke für die Tips ![]()
Danke Andreas ![]()
Eine Anmerkung noch zum Xprfwriter.
Scheinbar wird der Pfad beim Compiler nicht aktualisiert, wenn man die
Datei ändert. Wenn ich nach der Änderung den Interpreter starte, wird
der geänderte Code gestartet.Beim Start des Compilers wird eine frühere
Version compiliert.:(
Ansonsten ist die IDE große Klasse !
[BLOCK]
Set("FastMode",1)
$H windows.ph
$H messages.ph
Declare brush&
Proc editcall
Parameters wnd&,msg&,wparam&,lparam&
IF msg&=~WM_CTLCOLOREDIT
'If Lparam&=multiedit&
IF brush&
~DeleteObject(brush&)
EndIf
brush&=~CreateSolidBrush(Rgb(25,5,255)) Farbe
~SetBkMode(wParam&,~TRANSPARENT)
~SetTextColor(wParam&,RGB(205,5,0))
' wParam Handle to the device context for the static control 'window.
' lParam Handle to the static control.
RETURN brush&
'EndIf
If Lparam&=edit&
IF brush&
~DeleteObject(brush&)
EndIf
brush&=~CreateSolidBrush(Rgb(255,5,255))
~SetBkMode(wParam&,~TRANSPARENT)
~SetTextColor(wParam&,RGB(25,5,25))
' wParam Handle to the device context for the static control
' window.
' lParam Handle to the static control.
RETURN brush&
endif
EndIf
If msg&=~WM_CLOSE
~DeleteObject(brush&)
~RemoveProp(edit&,"editcall")
~RemoveProp(multiedit&,"editcall")
raus&=1
Endif
RETURN ~CallWindowProc(editcallback&,wnd&,msg&,wparam&,lparam&)
EndProc
cls
var editcallback&=~SetWindowLong(%hwnd,~GWL_WNDPROC,ProcAddr("editcall",4))
var edit&=Create("EDIT",%hwnd,"",16,96,60,20)
var multiedit&=Create("Multiedit",%hwnd,"",16,136,120,120)
Var raus&=0
WhileNot raus&
WaitInput
EndWhile
End
[/BLOCK]
Ich will beiden Controls unabhängig voneinander Farben
(Text:-),Hintergrund:-),Markierung:() zuweisen.
Wieso funktioniert die Abfrage von Lparam& nicht![]()
Der Versuch mit zwei Callback-Routinen
ist auch gescheitert.:(
Wer kann mir einen Tip geben. :smile:
(xprofan 11,XP prof mit allen SP)