[WinAPI] Textfarbe von Toolbar ändern

Ansonsten fällt mir nichts anderes ein außer es selbst zu zeichnen.

Da wirst Du wohl nicht drum herum kommen.
Ich habe hier ein kleines snippet, mit dem ich Zeilennummern auf einen Gutter zeichne....
Wie gesagt, Du darfst die DefProc nicht aufrufen, dann geht das.
Leider arbeite ich an diesen Projekt in assembler, aber der Sinn dürfte wohl
heraus zulesen sein:
Code:
proc WindowProc hwnd,wmsg,wparam,lparam
  push  ebx esi edi
  cmp  [wmsg],WM_CREATE
   je   .wmcreate

   cmp   [wmsg],WM_HSCROLL
   je   .wmhscroll

  cmp  [wmsg],WM_COMMAND
  je  .wmcommand
  cmp  [wmsg],WM_DESTROY
  je  .wmdestroy
  .defwndproc:
  invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
  jmp  .finish


  .wmcreate:
   invoke  GetModuleHandle,0
   mov  [wcCmd.hInstance],eax
   invoke  RegisterClass,wcCmd
  test  eax,eax
  jz  .errorcreatemdiwindow

   invoke  CreateWindowEx,WS_EX_WINDOWEDGE,_classCmd,_CmdText,\
     WS_CHILD+WS_VISIBLE+WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN,\
     100,100,400,400,[hwnd],CommandEditorID,[wcCmd.hInstance],0
   cmp   eax,0
   je   .errorcreatemdiwindow

   mov   [CommandWindow.hwnd],eax
   mov   eax,[hwnd]
   mov   [CommandWindow.parent],eax
   mov   [CommandWindow.Location.Top],100
   mov   [CommandWindow.Location.Left],100
   mov   [CommandWindow.Location.Height],400
   mov   [CommandWindow.Location.Width],400
   jmp   .cmdwinok

  .wmhscroll:
   mov  eax,[wparam]
  and  eax,0FFFFh
   cmp   eax,SB_LINELEFT
   je   .scrollleft
   cmp   eax,SB_LINERIGHT
   je   .scrollright

   jmp   .finish

  .scrollleft:
   invoke  ScrollWindow,[MainWindow.hwnd],+42,0,NULL,NULL
   jmp   .finish
  .scrollright:
   invoke  ScrollWindow,[MainWindow.hwnd],-42,0,NULL,NULL
   jmp   .finish

  .errorcreatemdiwindow:
   stdcall   LastErrorBox,dword eax
   jmp   .finish

  .cmdwinok:
   invoke   ShowWindow,[CommandWindow.hwnd],SW_SHOW
  jmp  .finish
  .wmcommand:
  mov  eax,[wparam]  ; hier das meinte ich 
  and  eax,0FFFFh  ; mit SubMessages
  cmp  eax,IDM_NEW
  je  .new
  cmp  eax,IDM_ABOUT
  je  .about
  cmp  eax,IDM_EXIT
  je  .wmdestroy
   cmp  eax,IDM_OPEN
   je  .open
   cmp   eax,IDM_RUNAPP
   je   .runapp

   jmp  .defwndproc

  .open:
   stdcall   getfileopen,[hwnd]
  jmp  .finish
  .runapp:
   call   saveandrun
   jmp   .finish

  .new:
  invoke  SendMessage,[edithwnd],WM_SETTEXT,0,0
  jmp  .finish
  .about:
  invoke  MessageBox,[hwnd],_about_text,_about_title,MB_OK
  jmp  .finish


  .wmdestroy:
   call   FreeProgramMemory
  invoke  PostQuitMessage,0
  xor  eax,eax
  .finish:
  pop  edi esi ebx
  ret
endp


proc makeLineNumber hwnd, hdc
local   oldLine dd ?

;   invoke   RedrawWindow,[hwnd],tmpRect,NULL,RDW_ALLCHILDREN+RDW_INTERNALPAINT

   invoke  SendMessage,[hwnd],EM_GETRECT,0,richEditRect
   mov   eax,[richEditRect.bottom]
   sub   eax,[richEditRect.top]
   mov   [iRectHeight], eax

   invoke   GetTextMetrics,[hdc],tm
   mov   eax,[iRectHeight]
   cdq
   idiv   dword [tm.tmHeight]
   mov   [iMaxNumberOfLines],eax


   invoke    SendMessage,[hwnd],EM_GETFIRSTVISIBLELINE,0,0
   mov   [iFirstVisibleLine],eax

;   invoke sprintf,read_buffer,_numstring,eax
;   invoke  MessageBox,[hwnd],read_buffer,_about_title,MB_OK

   mov   [iLineChar],0
   mov   [iLineNumber],0

   mov   [counter],0
   mov   [oldLine],1
   mov   eax,1
   push   eax
.nextline:
   mov   edi,[counter]
   cmp   edi,[iMaxNumberOfLines]
   je   .finish
   
   add   edi,[iFirstVisibleLine]
   push   edi
   invoke   SendMessage,[hwnd],EM_LINEINDEX,edi,0
   mov   [iLineChar],eax

   invoke   SendMessage,[hwnd],EM_LINEFROMCHAR,[iLineChar],0
   mov   [iLineNumber],eax
   cmp   [iLineNumber],-1
   je   .finish

   mov   eax,[iLineNumber]
   add   eax,1
   mov   [iLineNumber],eax

   invoke  sprintf,read_buffer,_numstring,[iLineNumber]
   invoke  SendMessage,[hwnd],EM_POSFROMCHAR,pl,[iLineChar]

   mov   [tmpRect.right],48
   mov   [tmpRect.left],0
   mov   eax,[richEditRect.bottom]
   mov   [tmpRect.bottom],eax
   mov   eax,[pl.y]

   mov   [tmpRect.top], eax
   invoke   DrawText,[hdc],read_buffer,3,tmpRect,DT_RIGHT


   mov   edi,[counter]
   add   edi,1
   mov   [counter],edi

.fini:

   jmp   .nextline
.finish:
   ret
endp
 
Ja, das mit Submessages weiß ich schon, jedoch gibt's keine bei der WM_PAINT Message.

Ich habe jetzt alles fertig und es funktioniert soweit. Ich glaube Code brauch ich hier keinen zu liefern, da dies ja nicht schwierig ist, und jeder andere Vorstellungen vom Visuellen Design hat. Thema kann somit als abgehackt markiert werden.

Danke noch mal an dich @jkallup :)
 

Neue Beiträge

Zurück