gdi problem

Windows specific questions.
bluatigro
Posts: 651
Joined: Apr 25, 2012 10:35
Location: netherlands

gdi problem

Postby bluatigro » May 03, 2012 8:49

i have 2 questions :
-1: why dont i get a blank screen ?
-2: how do i lose the blue bar at the top

Code: Select all



#include once "windows.bi"

dim shared as integer key( 255 )
dim shared as integer mouse_x
dim shared as integer mouse_y
dim shared as integer mouse_left
dim shared as integer mouse_right
dim shared as integer frame_timer

declare function        WinMain     ( byval hInstance as HINSTANCE, _
                                      byval hPrevInstance as HINSTANCE, _
                                      byval szCmdLine as string, _
                                      byval iCmdShow as integer ) as integer
                                 
declare sub opengl_init( w as integer , h as integer )

end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )

'':::::
function WndProc ( byval hWnd as HWND, _
                   byval wMsg as UINT, _
                   byval wParam as WPARAM, _
                   byval lParam as LPARAM ) as LRESULT
   
  function = 0
  dim rct as RECT
  dim pnt as PAINTSTRUCT
  dim hDC as HDC

  select case( wMsg )
    case WM_CREATE     
''      settimer hWnd , frame_timer , 40 , null
      exit function
    case WM_TIMER
      select case wParam
      case frame_timer
        GetClientRect( hWnd, @rct )
        invalidaterect hWnd , @rct , false
      case else
      end select
      exit function
    case WM_KEYDOWN
      if( lobyte( wParam ) = 27 ) then
            PostQuitMessage 0
         end if
      key( wParam ) = true
      exit function
    case WM_LBUTTONDOWN
      mouse_left = true
      exit function
    case WM_RBUTTONDOWN
      mouse_right = true
      exit function
    case WM_KEYUP
      key( wParam ) = false
      exit function
    case WM_LBUTTONUP
      mouse_left = false
      exit function
    case WM_RBUTTONUP
      mouse_right = false
      exit function
    case WM_MOUSEMOVE
      mouse_x = loword( lParam )
      mouse_y = hiword( lParam )
    case WM_PAINT
      hDC = BeginPaint( hWnd, @pnt )
      GetClientRect( hWnd, @rct )

      dim redpen as HPEN
      '' PS_SOLID PS_DOT PS_DASH PS_DASHDOT PS_DASHDOTDOT
      redpen = CreatePen( PS_SOLID , 5 , RGB( 255 , 0 , 0 ) )
      dim as HPEN oldpen = SelectObject( hDc , redpen )

      dim yellowbrush as HBRUSH
      '' HS_BDIAGONAL HS_CROSS HS_DIAGCROSS HS_FDIAGONAL HS_HORIZONTAL HS_VERTICAL     
''      yellowbrush = CreateHatchBrush( HS_DIAGCROS , RGB( 255 , 255 , 0 ) )
      yellowbrush = CreateSolidBrush( RGB( 255 , 255 , 0 ) )
      dim as HBRUSH oldbrush = SelectObject( hDc , yellowbrush )
     
      setpixel hDc , 50 , 50 , RGB( 0 , 0 , 255 )
     
      movetoex hDc , 60 , 50 , null
      lineto hDc , 100 , 200
     
      rectangle hDc , 200 , 50 , 300 , 200
     
      ellipse hDc , 400 , 50 , 500 , 200
     
      selectobject hDc , oldbrush
      deleteobject yellowbrush
      selectobject hDc , oldpen
      deleteobject redpen
           
      EndPaint( hWnd, @pnt )
      exit function           
    case WM_DESTROY
      PostQuitMessage( 0 )
      exit function
  end select
  function = DefWindowProc( hWnd, wMsg, wParam, lParam )   
end function

'':::::
function WinMain ( byval hInstance as HINSTANCE, _
                   byval hPrevInstance as HINSTANCE, _
                   byval szCmdLine as string, _
                   byval iCmdShow as integer ) as integer   
     
    dim wMsg as MSG
    dim wcls as WNDCLASS     
    dim hWnd as HWND
     
    function = 0
     
    with wcls
       .style         = CS_HREDRAW or CS_VREDRAW
       .lpfnWndProc   = @WndProc
       .cbClsExtra    = 0
       .cbWndExtra    = 0
       .hInstance     = hInstance
       .hIcon         = LoadIcon( NULL, IDI_APPLICATION )
       .hCursor       = LoadCursor( NULL, IDC_ARROW )
       .hbrBackground = GetStockObject( BLACK_BRUSH )
       .lpszMenuName  = NULL
       .lpszClassName = @"HelloWin"
    end with
         
    if( RegisterClass( @wcls ) = FALSE ) then
       MessageBox( null, "Failed to register wcls", "Error", MB_ICONERROR )
       exit function
    end if
   
    hWnd = CreateWindowEx( 0, _
                       @"HelloWin", _
                           "", _
                           WS_OVERLAPPEDWINDOW or WS_MAXIMIZE , _
                           0 , _
                           0 , _
                           CW_USEDEFAULT, _
                           CW_USEDEFAULT, _
                           NULL, _
                           NULL, _
                           hInstance, _
                           NULL )
                         

    ShowWindow( hWnd, SW_SHOWMAXIMIZED )''iCmdShow )
    UpdateWindow( hWnd )
     
    while( GetMessage( @wMsg, NULL, 0, 0 ) <> FALSE )   
        TranslateMessage( @wMsg )
        DispatchMessage( @wMsg )
    wend
   
    function = wMsg.wParam

end function
VANYA
Posts: 1370
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: gdi problem

Postby VANYA » May 03, 2012 9:31

Use BGR instead of RGB
codeFoil
Posts: 255
Joined: Dec 22, 2011 4:45
Location: United States
Contact:

Re: gdi problem

Postby codeFoil » May 04, 2012 0:56

Concerning the title bar, consult http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx.

Concerning "a blank screen", I am not sure what it is you are asking. Your code creates a maximized top level window that has a black background. What result were you expecting?
alfakilo
Posts: 117
Joined: Oct 02, 2009 9:18
Location: Estonia

Re: gdi problem

Postby alfakilo » May 04, 2012 14:20

deleted
Last edited by alfakilo on Jul 07, 2014 19:01, edited 1 time in total.
bluatigro
Posts: 651
Joined: Apr 25, 2012 10:35
Location: netherlands

Re: gdi problem

Postby bluatigro » May 07, 2012 12:20

this i can use

thans

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 3 guests