PureBasic - форум

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » PureBasic - форум » Вопросы по PureBasic » Пиксел экрана


Пиксел экрана

Сообщений 1 страница 3 из 3

1

Не могу понять почему пиксел не тот какой мне нужен. Весь череп уже до лысины исчесал  %-)  Мне нужен цвет рядышком с гаджетом #Text_2  для установки его фона. Подскажите пожалуйста. Не знаю может меня глючит или комп, вроде все правильно, а тем не менее....

Код:
Enumeration
  #Window_0
EndEnumeration

Enumeration
  #Text_0
  #Editor_1
  #Text_2
  #Radio_0
  #Radio_1
EndEnumeration

Enumeration
  #Font_Text_0
  #Font_Text_2
EndEnumeration

Enumeration
  #BackgroundImage_Window_0
EndEnumeration

Global BackgroundImage_Window_0_Brush

DataSection
  BackgroundImage_Window_0:
  IncludeBinary "Фон5.bmp"
EndDataSection

Define.l Event, EventWindow, EventGadget, EventType, EventMenu

Procedure GetPixel_Color(x,y) 
  sysviewDC = GetDC_(0) 
  ProcedureReturn GetPixel_(sysviewDC,x, y ) 
EndProcedure

Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 411, 129, 800, 600, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
    TextGadget(#Text_0, 50, 30, 695, 20, "", #PB_Text_Center|#SS_CENTERIMAGE)
    EditorGadget(#Editor_1, 470, 100, 290, 350)
    TextGadget(#Text_2, 570, 75, 95, 20, "", #PB_Text_Center|#SS_CENTERIMAGE)
    ; Gadget Fonts
    SetGadgetFont(#Text_0, LoadFont(#Font_Text_0, "Microsoft Sans Serif", 16, 784))
    SetGadgetFont(#Text_2, LoadFont(#Font_Text_2, "Arial", 12, 272))
    ; Gadget Colors
    SetGadgetColor(#Text_0,#PB_Gadget_BackColor,RGB(217, 253, 217))
    SetGadgetColor(#Text_0,#PB_Gadget_FrontColor,RGB(86, 4, 68))
    nn=GetPixel_Color(WindowX(#Window_0)+569,WindowY(#Window_0)+113)
    SetGadgetColor(#Text_2,#PB_Gadget_BackColor,RGB(Red(nn),Green(nn),Blue(nn)))
    Debug WindowX(#Window_0)+569
    Debug WindowY(#Window_0)+113
    Debug Str(Red(nn))+" "+Str(Green(nn))+" "+Str(Blue(nn))
    SetGadgetColor(#Text_2,#PB_Gadget_FrontColor,RGB(255, 0, 0))
    SetGadgetColor(#Editor_1,#PB_Gadget_BackColor,RGB(219, 252, 227))
    SetGadgetColor(#Editor_1,#PB_Gadget_FrontColor,RGB(10, 10, 10))    
    ; Window Background Image
    BackgroundImage_Window_0_Brush = CreatePatternBrush_(CatchImage(#BackgroundImage_Window_0, ?BackgroundImage_Window_0))
    If BackgroundImage_Window_0_Brush
      SetClassLong_(WindowID(#Window_0), #GCL_HBRBACKGROUND, BackgroundImage_Window_0_Brush)
      RedrawWindow_(WindowID(#Window_0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN)
      FreeImage(#BackgroundImage_Window_0)
    EndIf
 
  EndIf
EndProcedure


OpenWindow_Window_0()
;{- Event loop
Repeat
  Event = WaitWindowEvent()
  Select Event
    ; ///////////////////
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = #Text_0
      ElseIf EventGadget = #Editor_1
      ElseIf EventGadget = #Text_2
      EndIf
    ; ////////////////////////
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = #Window_0
        CloseWindow(#Window_0)
        Break
      EndIf
  EndSelect
ForEver
;
;}
If BackgroundImage_Window_0_Brush
  DeleteObject_(BackgroundImage_Window_0_Brush)
EndIf

0

2

haav написал(а):

Мне нужен цвет рядышком с гаджетом #Text_2  для установки его фона

А если так

Код:
Enumeration
  #Window_0
EndEnumeration

Enumeration
  #Text_0
  #Editor_1
  #Text_2
  #Radio_0
  #Radio_1
EndEnumeration

Enumeration
  #Font_Text_0
  #Font_Text_2
EndEnumeration

Enumeration
  #BackgroundImage_Window_0
EndEnumeration

Global BackgroundImage_Window_0_Brush

DataSection
  BackgroundImage_Window_0:
  IncludeBinary "E:\Безимени-1.bmp"
EndDataSection

Define.l Event, EventWindow, EventGadget, EventType, EventMenu

Procedure GetPixel_Color(x,y) 
  sysviewDC = GetDC_(0) 
  ProcedureReturn GetPixel_(sysviewDC,x, y ) 
EndProcedure

Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 411, 129, 800, 600, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
    BackgroundImage_Window_0_Brush = CreatePatternBrush_(CatchImage(#BackgroundImage_Window_0, ?BackgroundImage_Window_0))
    If BackgroundImage_Window_0_Brush
      SetClassLong_(WindowID(#Window_0), #GCL_HBRBACKGROUND, BackgroundImage_Window_0_Brush)
      RedrawWindow_(WindowID(#Window_0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN)
      FreeImage(#BackgroundImage_Window_0)
    EndIf
    TextGadget(#Text_0, 50, 30, 695, 20, "", #PB_Text_Center|#SS_CENTERIMAGE)
    EditorGadget(#Editor_1, 470, 100, 290, 350)
    nn=GetPixel_Color(WindowX(#Window_0)+569,WindowY(#Window_0)+113)
    TextGadget(#Text_2, 570, 75, 95, 20, "2", #PB_Text_Center|#SS_CENTERIMAGE)
    ; Gadget Fonts
    SetGadgetFont(#Text_0, LoadFont(#Font_Text_0, "Microsoft Sans Serif", 16, 784))
    SetGadgetFont(#Text_2, LoadFont(#Font_Text_2, "Arial", 12, 272))
    ; Gadget Colors
    SetGadgetColor(#Text_0,#PB_Gadget_BackColor,RGB(217, 253, 217))
    SetGadgetColor(#Text_0,#PB_Gadget_FrontColor,RGB(86, 4, 68))
    
    SetGadgetColor(#Text_2,#PB_Gadget_BackColor,RGB(Red(nn),Green(nn),Blue(nn)))
    Debug WindowX(#Window_0)+569
    Debug WindowY(#Window_0)+113
    Debug Str(Red(nn))+" "+Str(Green(nn))+" "+Str(Blue(nn))
    ;SetGadgetColor(#Text_2,#PB_Gadget_FrontColor,RGB(255, 0, 0))
    SetGadgetColor(#Editor_1,#PB_Gadget_BackColor,RGB(219, 252, 227))
    SetGadgetColor(#Editor_1,#PB_Gadget_FrontColor,RGB(10, 10, 10))    
    ; Window Background Image
;     BackgroundImage_Window_0_Brush = CreatePatternBrush_(CatchImage(#BackgroundImage_Window_0, ?BackgroundImage_Window_0))
;     If BackgroundImage_Window_0_Brush
;       SetClassLong_(WindowID(#Window_0), #GCL_HBRBACKGROUND, BackgroundImage_Window_0_Brush)
;       RedrawWindow_(WindowID(#Window_0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN)
;       FreeImage(#BackgroundImage_Window_0)
;     EndIf
 
  EndIf
EndProcedure


OpenWindow_Window_0()
;{- Event loop
Repeat
  Event = WaitWindowEvent()
  Select Event
    ; ///////////////////
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = #Text_0
      ElseIf EventGadget = #Editor_1
      ElseIf EventGadget = #Text_2
      EndIf
    ; ////////////////////////
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = #Window_0
        CloseWindow(#Window_0)
        Break
      EndIf
  EndSelect
ForEver
;
;}
If BackgroundImage_Window_0_Brush
  DeleteObject_(BackgroundImage_Window_0_Brush)
EndIf

0

3

Благодарю!

0


Вы здесь » PureBasic - форум » Вопросы по PureBasic » Пиксел экрана