Author Topic: Main dialog.exe calling a splash dll  (Read 3399 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
Main dialog.exe calling a splash dll
« on: April 17, 2018, 05:04:46 AM »
Hello
I have created a main program "DialogWind.exe" to call a splash screen dll "mysplash.dll"

this is a test of concept that a main dialog window can call a splash screen and then revert
control back to the main dialog.  but unfortunately when the splash screen fade out, it also closes
the main dialog program. 

How to stop this from happening  so that the main dialog window does not close after splash
screen faded away?  appreciate any help

here is the main dialog code DialogWind.o2bas

Code: [Select]
' uses Dialog as main
' DialogWind.o2bas
$ filename "DialogWind.exe"
uses RTL64



sys wndproc         'Placeholder, winutil.inc
#case capital

typedef sys SYS     'FileDialog.inc
typedef char CHAR   'FileDialog.inc
% FileDialogs       'opens FileDialog in winutil.inc

uses winutil
uses glWinUtil      'OpenGL
uses imgwin

Declare Function Splash  Lib "mySplash.dll"() as Long

'% review           'opens console
uses dialogs
'namespace

#autodim off

% DS_CENTER=0x0800
% SM_CXBORDER=5
% SM_CYBORDER=6
% SWP_NOZORDER=4
% HWND_TOPMOST= -1
% HORZRES=8
% VERTRES=10



'Ids for menu
#define IDM_Load       1110
#define IDM_Exit       1111
#define IDM_Play       1112
#define IDM_Reset      1113
#define IDM_Filter     1114
#define IDM_Light      1115
#define IDM_Blend      1116
#define IDM_FullScreen 1117
#define IDM_Help       1118
#define IDM_Right      1119
#define IDM_Left       1120
#define IDM_Up         1121
#define IDM_Down       1122
#define IDM_PgUp       1123
#define IDM_PgDown     1124
#define IDM_Splash       1133

'Ids for text controls in Help
% IDC_LText1=1131
% IDC_LText2=1132

#lookahead 'for subs and functions

==============================================

'MAIN CODE
=============================================

string fn=""



sys hMenu
sys hAccel

int GdiplusToken
GLuint texture[3]  'Storage for three Texture
GLuint wi[1],ht[1]

'Prepare Textures
'----------------
glGenTextures 3, texture

GLfloat    xrot   'X Rotation
GLfloat    yrot   'Y Rotation
GLfloat xspeed    'X Rotation Speed
GLfloat yspeed    'Y Rotation Speed

GLfloat z=-5.0f   'Depth Into The Screen

GLfloat LightAmbient[]=  { 0.5f, 0.5f, 0.5f, 1.0f }
GLfloat LightDiffuse[]=  { 1.0f, 1.0f, 1.0f, 1.0f }
GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }

GLuint filter=1    'Which Filter To Use

sys hDlgHDC


'============================================
function DlgProc( sys hDlg, uint uMsg, sys wParam, lParam ) as sys callback
 
  static bool p_toggle   'Play ON/OFF
  static bool reset=true 'Original state of image
 

  select case uMsg

    case WM_INITDIALOG
      hMenu = initMenu(hDlg)
      if SetMenu( hDlg, hMenu ) = 0 then
        mbox "SetMenu hMenu failed!"
      end if

      sys hGLrc
      hDlgHDC = GetDC( hDlg )
     
      'glWinUtil.inc
      SelectPixelFormat(hDlgHDC, 1)

      hGLrc = wglCreateContext( hDlgHDC )
      if hGLrc = 0 then
        MessageBox( hDlg, "wglCreateContext failed", 0, 0 )
        DestroyWindow( hDlg )
      end if

      if wglMakeCurrent( hDlgHDC, hGLrc ) = 0 then
        MessageBox( hDlg, "wglMakeCurrent failed", 0, 0 )
        DestroyWindow( hDlg )
      end if

 

    case WM_PAINT
   '   DrawGlScene()
      SwapBuffers( hDlgHDC )

    case WM_TIMER
   '   xrot += xspeed   'Inc x rotation
  '    yrot += yspeed   'Inc y rotation
  '    DrawGlScene()
      SwapBuffers( hDlgHDC)
           
    case WM_SIZE
      'LoWord=Width, HiWord=Height   
    '  ReSizeGLScene(loword(lParam),hiword(lParam))

    case WM_ERASEBKGND
      return 0
     

    case WM_COMMAND

      select case loword(wParam)
 
          case IDM_Splash
                  '  print "splash"
                    Splash()

          case IDCANCEL, IDM_Exit
                DestroyWindow( hDlg )

      end select


    case WM_CLOSE
      DestroyWindow( hDlg )

    case WM_DESTROY
      glDeleteTextures 3, texture
      Gdiplus 0
     
      if hGLrc then                             'Rendering Context?
        if not wglMakeCurrent(null,null) then   'Release the DC And RC Contexts   
          MessageBox(null,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION)
        end if
        if not wglDeleteContext(hGLrc) then     'Delete the RC
          MessageBox(null,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION)
        end if
        hGLrc=null                              'Set RC to null
      end if

      if hDlgHDC then
        if not ReleaseDC(hDlg,hDlgHDC) then     'Release The DC
          MessageBox(null,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION)
          hDlgHDC=null                          'Set DC to null
        end if
      end if               
      PostQuitMessage 0

  end select

  return 0
end function




'====================================================================

sub WinMain()

   sys hDlg, bRet
   MSG Msg

   sys lpdt
   dyn::init(lpdt)

   Dialog( 0, 0, 0, 320, 240, "Dialog ", lpdt,
           WS_OVERLAPPEDWINDOW or DS_CENTER or WS_VISIBLE )

   hDlg = CreateModelessDialog( null, @DlgProc, 0, lpdt )


   while (bRet := GetMessage(&Msg, null, 0, 0)) != 0
     if bRet = -1 then
       'show an error message
       print "Error in Message Loop"
       end
     else
       if TranslateAccelerator( hDlg, hAccel, @Msg ) = 0 then     
         if not IsDialogMessage(hDlg, &Msg) then
 
           TranslateMessage(&Msg)
           DispatchMessage(&Msg)
 
         end if
       end if
     end if
   wend

end sub

WinMain()



'====================================================================

function initMenu(sys hDlg) as sys

   MENU(hMenu)

   BEGIN
     POPUP "&File"
     BEGIN
       MENUITEM "&Load Image..." tab "Ctrl+O", IDM_Load
       MENUITEM "SEPARATOR"
       MENUITEM "E&xit" tab "Alt+F4", IDM_Exit
     ENDMenu
     POPUP "&View"
     BEGIN
       MENUITEM "&Toggle Start / Stop" tab "Ctrl+P", IDM_Play
       MENUITEM "&Reset" tab "Ctrl+R", IDM_Reset
       MENUITEM "SEPARATOR"
       MENUITEM "&Splash" tab "Ctrl+S", IDM_Splash
     ENDMenu
 

   ENDMenu



   'Accelerators
   indexbase 0
   '14 shortcuts 0-13
   ACCEL accl[13] = {
   {FVIRTKEY | FCONTROL, asc("O"), IDM_Load      },
   {FVIRTKEY | FCONTROL, asc("P"), IDM_Play      },
   {FVIRTKEY | FCONTROL, asc("R"), IDM_Reset     },
  {FVIRTKEY | FCONTROL, asc("S"), IDM_Splash     },
   {FVIRTKEY,            asc("F"), IDM_Filter    },
   {FVIRTKEY,            asc("L"), IDM_Light     },
   {FVIRTKEY,            asc("B"), IDM_Blend     },
   {FVIRTKEY,            VK_RIGHT, IDM_Right     },
   {FVIRTKEY,            VK_LEFT,  IDM_Left      },
   {FVIRTKEY,            VK_UP,    IDM_Up        },
   {FVIRTKEY,            VK_DOWN,  IDM_Down      },     
   {FVIRTKEY,            VK_PRIOR, IDM_PgUp      },
   {FVIRTKEY,            VK_NEXT,  IDM_PgDown    },     
   {FVIRTKEY,            VK_F11,   IDM_FullScreen},
   {FVIRTKEY,            VK_F1,    IDM_Help      }
   }
 
   hAccel = CreateAcceleratorTable( @accl, 14 )

   return hMenu
end function











chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #1 on: April 17, 2018, 05:05:52 AM »
here is the splash screen dll   mysplash.dll

Code: [Select]
'   includepath "$\inc\"
'  Apr 17 2018
'http://www.oxygenbasic.org/forum/index.php?topic=1639.0

' mysplash.o2bas
  % dll
  % FileName  "mySplash.dll"
  uses RTL64

'  Set the width and height of the display window
  % width     300
  % height    300
 
  $ fontA     "Arial",FW_SEMIBOLD

  $ title     "Splash"
   % ExplicitMain
 
 '  Note that you need to place OpenglSceneFrame.inc , winUtil.inc
'   and glWinUtil.inc into the same folder when compiling
   include   "OpenglSceneFrame.inc"

   

'  Note that we must specify exactly these equates
'  all in uppercase ,  otherwise it can results in compilation errors
#define GL_TRIANGLES        0x0004
#define GL_TRIANGLE_FAN 0x0006
#define GL_QUAD_STRIP     0x0008
#define  SWP_NOSIZE         0x0001
#define  SWP_NOMOVE      0x0002
#define   SWP_SHOWWINDOW      0x0040
#define  SW_SHOW   5
#define  SM_CYCAPTION  4




'========================
' this center the display window
' on the screen
' but it was not use in this program
sub Center(sys hwnd)
    RECT rc
    sys x,y
    GetWindowRect(hwnd,&rc)
    x = (GetSystemMetrics(SM_CXSCREEN) - (rc.right-rc.left))\2
    y = (GetSystemMetrics(SM_CYSCREEN) -
           (rc.bottom-rc.top+GetSystemMetrics(SM_CYCAPTION)))\2
 
    SetWindowPos (hWnd, 0, x, y, 0, 0, SWP_NOSIZE)
end sub

 




  sub initialize(sys hWnd)
  '=======================
       
  end sub
  '




  sub scene(sys hWnd)
  '==================
  '
  static single s1,s2,s3,s4,ang1

'DISPLAY AND FADE OUT
  if not picking then
    static Counter '60Hz Frame counter
    counter++
    if counter>180 'AFTER 3 SECONDS
      int WindowOpacity
      int t=(counter-180)*255/120 '2 sec fade
      if t>255 then t=255
      WindowOpacity=255-t
      if counter=300 '5 SECONDS
        CloseWindow 'REQUEST SHUT DOWN
      end if
      'Set WS_EX_LAYERED on this window
      SetWindowLong(hwnd, GWL_EXSTYLE,
      GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)
      SetLayeredWindowAttributes(hwnd, 0, WindowOpacity, LWA_ALPHA);
    end if
  end if

'  increase this angle for faster rotation between 1 and 10
   angi1=7
  '
  glLoadIdentity
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

 '  Greenish Beige background color
   glClearColor .91,.94,.82,1


'  ' display the text label1
    glPushMatrix
    gltranslatef  -.63,.8,-2.5
    glScalef( 0.25, 0.25, .01)
    glColor3f  0.20, 0.0, 1.0
    gPrint    "Your Product"


 ' display the text label2
   gltranslatef  -5., -1.7,-1.0
'   glScalef( 0.15, 0.2, .01)
  glColor3f 1.0, 0.0, 0.0
   gPrint    "Label 2"




  '
  '
  s1=.2    'x y
  s2=-1    'z
  s3=0.5   'color
  s4=s3*.2 'color
  '
  glrotatef ang1, 0,0,1




  '
'   original square -- this work
' glbegin GL_QUADS
' glcolor4f   00,  s3,  s3, 1 : glvertex3f -s1, -s1,  s2
 ' glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
 ' glcolor4f   s4,   0,  s3, 1 : glvertex3f  s1,  s1,  s2
'  glcolor4f   s4,   0,  s3, 1 : glvertex3f -s1,  s1,  s2
'  glend


'   semi triangle  -- this work
'  glBegin  GL_TRIANGLE_FAN
   '     glcolor4f   00,  s3,  s3, 1  : glvertex3f  -s1, -s1,  s2   '1st triangle
   '      glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  -.3,-.1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  s1,  s1 ,  -s2   '2nd
    '      glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  -s1,  s2   '3rd
   '       glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  s1,  -s2      '4th
  '   glEnd

 '  Triangle  -- this work
'   ensure that  z = -1.  thru' out
 '  glBegin GL_TRIANGLES 
'       glColor3f 1.0, 0.0, 0.0 :   glVertex3f   0.0,  .3,-1.
'       glColor3f 0.0, 1.0, 0.0 :   glVertex3f  0.2, -0.1,-1.
'       glColor3f 0.0, 0.0, 1.0 :   glVertex3f  -0.2,-0.1,-1.
' glEnd


'  Triangle  -- this work
'   this place triangle off center and if we increase the  -ve z
'   the object gets smaller and will spin at a distance of 0.8 from the center
 '   glTranslatef .80, 0.0, -2.0
  ' glBegin GL_TRIANGLES
'  glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0,  .30,-1.0
'  glColor3f 0.0, 1.0, 0.0 : glVertex3f 0.26,-0.15,-1.0
 ' glColor3f 0.0, 0.0, 1.0 : glVertex3f-0.26,-0.15,-1.0
'  glEnd

'  this work
' Half red square rotated off center
'   glTranslatef 2.40,0.0,-10.0
'   glBegin(GL_QUADS)
'  glColor3f   1.0, 0.0, 1.0
'  glVertex3f -1.0,-1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f  1.0,-1.0, 0.0
'  glVertex3f  1.0, 1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f -1.0, 1.0, 0.0
'  glEnd


'  rotating  off center Cube  -- this work
 ' glTranslatef -2.0, -2.0, -12.0
 ' glBegin GL_QUADS
 ' glColor3f   0.0, 1.0, 0.0
 ' glVertex3f  1.0, 1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
'  glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f  1.0, 1.0, 1.0
 ' glColor3f   1.0, 0.5, 0.0
 ' glVertex3f  1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glColor3f   1.0, 0.0, 0.0
'  glVertex3f  1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f  1.0,-1.0, 1.0
  'glColor3f   1.0, 1.0, 0.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f  1.0, 1.0,-1.0
  'glColor3f   0.0, 0.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0, 1.0
' glColor3f  1.0, 0.0, 1.0
 ' glVertex3f 1.0, 1.0,-1.0
 ' glVertex3f 1.0, 1.0, 1.0
 ' glVertex3f 1.0,-1.0, 1.0
'  glVertex3f 1.0,-1.0,-1.0
' glEnd
 

' DrawDiamond   -- this work  very well
    glTranslatef 1.4,0.0,-20.0
      glbegin GL_TRIANGLE_FAN  'top part
          glcolor3ub 255,   0,   0 : glvertex3f  0, 0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
         glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
       glend
       glbegin GL_TRIANGLE_FAN    'bottom part
         glcolor3ub 255,   0,   0 : glvertex3f  0,-0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
      glend



    'draws a 3D cube object  -- drawcube  works
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
  '     glTranslatef 1.4,0.0,-7.0
  '    glBegin  GL_QUADS
  '      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
  '     glcolor3ub 255,0,0
   '    glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Top)
 '      glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Top)
  '     glVertex3f -0.5,  0.5,  0.5    ' Bottom left of the quad (Top)
  '     glVertex3f  0.5,  0.5,  0.5    ' Bottom right of the quad (Top)

   '    glcolor3ub 255,255,0
   '    glVertex3f  0.5, -0.5,  0.5    ' Top right of the quad (Bottom)
   '    glVertex3f -0.5, -0.5,  0.5    ' Top left of the quad (Bottom)
   '    glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Bottom)
   '    glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Bottom)

    '   glcolor3ub 255,0,255
    '   glVertex3f  0.5,  0.5,  0.5    ' Top right of the quad (Front)
    '   glVertex3f -0.5,  0.5,  0.5    ' Top left of the quad (Front)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom left of the quad (Front)
   '    glVertex3f  0.5, -0.5,  0.5    ' Bottom right of the quad (Front)

   '    glcolor3ub 0,0,255
   '    glVertex3f  0.5, -0.5, -0.5    ' Top right of the quad (Back)
    '   glVertex3f -0.5, -0.5, -0.5    ' Top left of the quad (Back)
    '   glVertex3f -0.5,  0.5, -0.5    ' Bottom left of the quad (Back)
    '   glVertex3f  0.5,  0.5, -0.5    ' Bottom right of the quad (Back)

   '    glcolor3ub 0,255,255
  '     glVertex3f -0.5,  0.5,  0.5    ' Top right of the quad (Left)
   '    glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Left)
    '   glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Left)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom right of the quad (Left)

    '   glcolor3ub 255,128,0
     '  glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Right)
    '   glVertex3f  0.5,  0.5,  0.5    ' Top left of the quad (Right)
    '   glVertex3f  0.5, -0.5,  0.5    ' Bottom left of the quad (Right)
    '   glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Right)
  '  glEnd
   
  sleep (2)
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
   glLoadIdentity
      glTranslatef 2.5, -2.90, -15.0            ' Move right 1.5 units and into the screen
      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
      glBegin  GL_QUADS
         glColor3f   0.0,  1.0,  0.0         ' Set the color to green
         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Top)
         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Top)
         glVertex3f -1.0,  1.0,  1.0         ' Bottom left of the quad (Top)
         glVertex3f  1.0,  1.0,  1.0         ' Bottom right of the quad (Top)

         glColor3f   1.0,  0.5,  0.0         ' Set the color to orange
         glVertex3f  1.0, -1.0,  1.0         ' Top right of the quad (Bottom)
         glVertex3f -1.0, -1.0,  1.0         ' Top left of the quad (Bottom)
         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Bottom)
         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Bottom)

         glColor3f   1.0,  0.0,  0.0         ' Set the color to red
         glVertex3f  1.0,  1.0,  1.0         ' Top right of the quad (Front)
         glVertex3f -1.0,  1.0,  1.0         ' Top left of the quad (Front)
         glVertex3f -1.0, -1.0,  1.0         ' Bottom left of the quad (Front)
         glVertex3f  1.0, -1.0,  1.0         ' Bottom right of the quad (Front)

         glColor3f   1.0,  1.0,  0.0         ' Set the color to yellow
         glVertex3f  1.0, -1.0, -1.0         ' Top right of the quad (Back)
         glVertex3f -1.0, -1.0, -1.0         ' Top left of the quad (Back)
         glVertex3f -1.0,  1.0, -1.0         ' Bottom left of the quad (Back)
         glVertex3f  1.0,  1.0, -1.0         ' Bottom right of the quad (Back)

         glColor3f   0.0,  0.0,  1.0         ' Set the color to blue
         glVertex3f -1.0,  1.0,  1.0         ' Top right of the quad (Left)
         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Left)
         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Left)
         glVertex3f -1.0, -1.0,  1.0         ' Bottom right of the quad (Left)

         glColor3f   1.0,  0.0,  1.0         ' Set the color to violet
         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Right)
         glVertex3f  1.0,  1.0,  1.0         ' Top left of the quad (Right)
         glVertex3f  1.0, -1.0,  1.0         ' Bottom left of the quad (Right)
         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Right)
      glEnd


   sleep (2)
 '   draw the pyramid using triangles
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the diamond smaller
 ' // Reset the view
      glLoadIdentity

      glTranslatef -1.5, -1.0, -10.0           ' Move left 1.5 units and into the screen
      glRotatef  ang1, 0.0, 1.0, 0.0          ' Rotate the triangle on the Y axis

      glBegin %GL_TRIANGLES
         ' Front
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Front)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f -1.0, -1.0,  1.0         ' Left of triangle (Front)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f  1.0, -1.0,  1.0         ' Right of triangle (Front)

         ' Right
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Right)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f  1.0, -1.0,  1.0         ' Left of triangle (Right)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f  1.0, -1.0, -1.0         ' Right of triangle (Right)

         ' Back
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Back)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f  1.0, -1.0, -1.0         ' Left of triangle (Back)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f -1.0, -1.0, -1.0         ' Right of triangle (Back)

         ' Left
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Left)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f -1.0, -1.0, -1.0         ' Left of triangle (Left)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f -1.0, -1.0,  1.0         ' Right of triangle (Left)
      glEnd





  '
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  end sub


  sub Release(sys hwnd)
  '====================
  end sub


Function Splash() as Long , export
' display the window and centralize it  using place = 2
MainWindow     width,height,%WS_POPUP ,2
End Function




chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #2 on: April 17, 2018, 05:11:19 AM »
here are all the exe and dll and inc files

Run   DialogWind.exe -->  View --> Splash

Splash screen appears and then fade away  but later on it  also closes the DialogWind program ??

chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #3 on: April 17, 2018, 07:01:40 AM »
i have replaced the closewindows statement with  PostQuitMessage 0
inside mySplash.o2bas 

then the main dialog is not close after splash screen faded away

but when i click on splash again there is an error message  -- registration fail

 it looks like the splash is still lurking in the memory and not close at all

Code: [Select]
'   includepath "$\inc\"
'  Apr 17 2018
'http://www.oxygenbasic.org/forum/index.php?topic=1639.0

' mysplash.o2bas
  % dll
  % FileName  "mySplash.dll"
  uses RTL64

'  Set the width and height of the display window
  % width     300
  % height    300
 
  $ fontA     "Arial",FW_SEMIBOLD

  $ title     "Splash"
   % ExplicitMain
 
 '  Note that you need to place OpenglSceneFrame.inc , winUtil.inc
'   and glWinUtil.inc into the same folder when compiling
   include   "OpenglSceneFrame.inc"

   

'  Note that we must specify exactly these equates
'  all in uppercase ,  otherwise it can results in compilation errors
#define GL_TRIANGLES        0x0004
#define GL_TRIANGLE_FAN 0x0006
#define GL_QUAD_STRIP     0x0008
#define  SWP_NOSIZE         0x0001
#define  SWP_NOMOVE      0x0002
#define   SWP_SHOWWINDOW      0x0040
#define  SW_SHOW   5
#define  SM_CYCAPTION  4




'========================
' this center the display window
' on the screen
' but it was not use in this program
sub Center(sys hwnd)
    RECT rc
    sys x,y
    GetWindowRect(hwnd,&rc)
    x = (GetSystemMetrics(SM_CXSCREEN) - (rc.right-rc.left))\2
    y = (GetSystemMetrics(SM_CYSCREEN) -
           (rc.bottom-rc.top+GetSystemMetrics(SM_CYCAPTION)))\2
 
    SetWindowPos (hWnd, 0, x, y, 0, 0, SWP_NOSIZE)
end sub

 




  sub initialize(sys hWnd)
  '=======================
       
  end sub
  '




  sub scene(sys hWnd)
  '==================
  '
  static single s1,s2,s3,s4,ang1

'DISPLAY AND FADE OUT
  if not picking then
    static Counter '60Hz Frame counter
    counter++
    if counter>180 'AFTER 3 SECONDS
      int WindowOpacity
      int t=(counter-180)*255/120 '2 sec fade
      if t>255 then t=255
      WindowOpacity=255-t
      if counter=300 '5 SECONDS
    '   CloseWindow 'REQUEST SHUT DOWN
        PostQuitMessage 0
      end if
      'Set WS_EX_LAYERED on this window
      SetWindowLong(hwnd, GWL_EXSTYLE,
      GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)
      SetLayeredWindowAttributes(hwnd, 0, WindowOpacity, LWA_ALPHA);
    end if
  end if

'  increase this angle for faster rotation between 1 and 10
   angi1=7
  '
  glLoadIdentity
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

 '  Greenish Beige background color
   glClearColor .91,.94,.82,1


'  ' display the text label1
    glPushMatrix
    gltranslatef  -.63,.8,-2.5
    glScalef( 0.25, 0.25, .01)
    glColor3f  0.20, 0.0, 1.0
    gPrint    "Your Product"


 ' display the text label2
   gltranslatef  -5., -1.7,-1.0
'   glScalef( 0.15, 0.2, .01)
  glColor3f 1.0, 0.0, 0.0
   gPrint    "Label 2"




  '
  '
  s1=.2    'x y
  s2=-1    'z
  s3=0.5   'color
  s4=s3*.2 'color
  '
  glrotatef ang1, 0,0,1




  '
'   original square -- this work
' glbegin GL_QUADS
' glcolor4f   00,  s3,  s3, 1 : glvertex3f -s1, -s1,  s2
 ' glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
 ' glcolor4f   s4,   0,  s3, 1 : glvertex3f  s1,  s1,  s2
'  glcolor4f   s4,   0,  s3, 1 : glvertex3f -s1,  s1,  s2
'  glend


'   semi triangle  -- this work
'  glBegin  GL_TRIANGLE_FAN
   '     glcolor4f   00,  s3,  s3, 1  : glvertex3f  -s1, -s1,  s2   '1st triangle
   '      glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  -.3,-.1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  s1,  s1 ,  -s2   '2nd
    '      glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  -s1,  s2   '3rd
   '       glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  s1,  -s2      '4th
  '   glEnd

 '  Triangle  -- this work
'   ensure that  z = -1.  thru' out
 '  glBegin GL_TRIANGLES 
'       glColor3f 1.0, 0.0, 0.0 :   glVertex3f   0.0,  .3,-1.
'       glColor3f 0.0, 1.0, 0.0 :   glVertex3f  0.2, -0.1,-1.
'       glColor3f 0.0, 0.0, 1.0 :   glVertex3f  -0.2,-0.1,-1.
' glEnd


'  Triangle  -- this work
'   this place triangle off center and if we increase the  -ve z
'   the object gets smaller and will spin at a distance of 0.8 from the center
 '   glTranslatef .80, 0.0, -2.0
  ' glBegin GL_TRIANGLES
'  glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0,  .30,-1.0
'  glColor3f 0.0, 1.0, 0.0 : glVertex3f 0.26,-0.15,-1.0
 ' glColor3f 0.0, 0.0, 1.0 : glVertex3f-0.26,-0.15,-1.0
'  glEnd

'  this work
' Half red square rotated off center
'   glTranslatef 2.40,0.0,-10.0
'   glBegin(GL_QUADS)
'  glColor3f   1.0, 0.0, 1.0
'  glVertex3f -1.0,-1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f  1.0,-1.0, 0.0
'  glVertex3f  1.0, 1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f -1.0, 1.0, 0.0
'  glEnd


'  rotating  off center Cube  -- this work
 ' glTranslatef -2.0, -2.0, -12.0
 ' glBegin GL_QUADS
 ' glColor3f   0.0, 1.0, 0.0
 ' glVertex3f  1.0, 1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
'  glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f  1.0, 1.0, 1.0
 ' glColor3f   1.0, 0.5, 0.0
 ' glVertex3f  1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glColor3f   1.0, 0.0, 0.0
'  glVertex3f  1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f  1.0,-1.0, 1.0
  'glColor3f   1.0, 1.0, 0.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f  1.0, 1.0,-1.0
  'glColor3f   0.0, 0.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0, 1.0
' glColor3f  1.0, 0.0, 1.0
 ' glVertex3f 1.0, 1.0,-1.0
 ' glVertex3f 1.0, 1.0, 1.0
 ' glVertex3f 1.0,-1.0, 1.0
'  glVertex3f 1.0,-1.0,-1.0
' glEnd
 

' DrawDiamond   -- this work  very well
    glTranslatef 1.4,0.0,-20.0
      glbegin GL_TRIANGLE_FAN  'top part
          glcolor3ub 255,   0,   0 : glvertex3f  0, 0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
         glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
       glend
       glbegin GL_TRIANGLE_FAN    'bottom part
         glcolor3ub 255,   0,   0 : glvertex3f  0,-0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
      glend



    'draws a 3D cube object  -- drawcube  works
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
  '     glTranslatef 1.4,0.0,-7.0
  '    glBegin  GL_QUADS
  '      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
  '     glcolor3ub 255,0,0
   '    glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Top)
 '      glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Top)
  '     glVertex3f -0.5,  0.5,  0.5    ' Bottom left of the quad (Top)
  '     glVertex3f  0.5,  0.5,  0.5    ' Bottom right of the quad (Top)

   '    glcolor3ub 255,255,0
   '    glVertex3f  0.5, -0.5,  0.5    ' Top right of the quad (Bottom)
   '    glVertex3f -0.5, -0.5,  0.5    ' Top left of the quad (Bottom)
   '    glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Bottom)
   '    glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Bottom)

    '   glcolor3ub 255,0,255
    '   glVertex3f  0.5,  0.5,  0.5    ' Top right of the quad (Front)
    '   glVertex3f -0.5,  0.5,  0.5    ' Top left of the quad (Front)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom left of the quad (Front)
   '    glVertex3f  0.5, -0.5,  0.5    ' Bottom right of the quad (Front)

   '    glcolor3ub 0,0,255
   '    glVertex3f  0.5, -0.5, -0.5    ' Top right of the quad (Back)
    '   glVertex3f -0.5, -0.5, -0.5    ' Top left of the quad (Back)
    '   glVertex3f -0.5,  0.5, -0.5    ' Bottom left of the quad (Back)
    '   glVertex3f  0.5,  0.5, -0.5    ' Bottom right of the quad (Back)

   '    glcolor3ub 0,255,255
  '     glVertex3f -0.5,  0.5,  0.5    ' Top right of the quad (Left)
   '    glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Left)
    '   glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Left)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom right of the quad (Left)

    '   glcolor3ub 255,128,0
     '  glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Right)
    '   glVertex3f  0.5,  0.5,  0.5    ' Top left of the quad (Right)
    '   glVertex3f  0.5, -0.5,  0.5    ' Bottom left of the quad (Right)
    '   glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Right)
  '  glEnd
   
  sleep (2)
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
   glLoadIdentity
      glTranslatef 2.5, -2.90, -15.0            ' Move right 1.5 units and into the screen
      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
      glBegin  GL_QUADS
         glColor3f   0.0,  1.0,  0.0         ' Set the color to green
         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Top)
         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Top)
         glVertex3f -1.0,  1.0,  1.0         ' Bottom left of the quad (Top)
         glVertex3f  1.0,  1.0,  1.0         ' Bottom right of the quad (Top)

         glColor3f   1.0,  0.5,  0.0         ' Set the color to orange
         glVertex3f  1.0, -1.0,  1.0         ' Top right of the quad (Bottom)
         glVertex3f -1.0, -1.0,  1.0         ' Top left of the quad (Bottom)
         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Bottom)
         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Bottom)

         glColor3f   1.0,  0.0,  0.0         ' Set the color to red
         glVertex3f  1.0,  1.0,  1.0         ' Top right of the quad (Front)
         glVertex3f -1.0,  1.0,  1.0         ' Top left of the quad (Front)
         glVertex3f -1.0, -1.0,  1.0         ' Bottom left of the quad (Front)
         glVertex3f  1.0, -1.0,  1.0         ' Bottom right of the quad (Front)

         glColor3f   1.0,  1.0,  0.0         ' Set the color to yellow
         glVertex3f  1.0, -1.0, -1.0         ' Top right of the quad (Back)
         glVertex3f -1.0, -1.0, -1.0         ' Top left of the quad (Back)
         glVertex3f -1.0,  1.0, -1.0         ' Bottom left of the quad (Back)
         glVertex3f  1.0,  1.0, -1.0         ' Bottom right of the quad (Back)

         glColor3f   0.0,  0.0,  1.0         ' Set the color to blue
         glVertex3f -1.0,  1.0,  1.0         ' Top right of the quad (Left)
         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Left)
         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Left)
         glVertex3f -1.0, -1.0,  1.0         ' Bottom right of the quad (Left)

         glColor3f   1.0,  0.0,  1.0         ' Set the color to violet
         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Right)
         glVertex3f  1.0,  1.0,  1.0         ' Top left of the quad (Right)
         glVertex3f  1.0, -1.0,  1.0         ' Bottom left of the quad (Right)
         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Right)
      glEnd


   sleep (2)
 '   draw the pyramid using triangles
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the diamond smaller
 ' // Reset the view
      glLoadIdentity

      glTranslatef -1.5, -1.0, -10.0           ' Move left 1.5 units and into the screen
      glRotatef  ang1, 0.0, 1.0, 0.0          ' Rotate the triangle on the Y axis

      glBegin %GL_TRIANGLES
         ' Front
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Front)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f -1.0, -1.0,  1.0         ' Left of triangle (Front)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f  1.0, -1.0,  1.0         ' Right of triangle (Front)

         ' Right
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Right)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f  1.0, -1.0,  1.0         ' Left of triangle (Right)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f  1.0, -1.0, -1.0         ' Right of triangle (Right)

         ' Back
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Back)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f  1.0, -1.0, -1.0         ' Left of triangle (Back)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f -1.0, -1.0, -1.0         ' Right of triangle (Back)

         ' Left
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Left)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f -1.0, -1.0, -1.0         ' Left of triangle (Left)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f -1.0, -1.0,  1.0         ' Right of triangle (Left)
      glEnd





  '
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  end sub


  sub Release(sys hwnd)
  '====================
  end sub


Function Splash() as Long , export
  ' display the window and centralize it  using place = 2
     MainWindow     width,height,%WS_POPUP ,2
End Function



chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #4 on: April 17, 2018, 07:31:17 AM »

i also tried  replacing closewindow with

 PostMessage(hwnd, %WM_CLOSE,0,0)

but it didn't work ?


Mike Lobanovsky

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #5 on: April 17, 2018, 07:45:20 AM »
PostQuitMessage 0 isn't logically correct here, Chris. This API is meant to shut down the entire process rather than just close a window. You could try PostMessage(hWnd, WM_CLOSE, 0, 0) but it won't work either. (I see you have already tried it yourself)
  • According to my Task Manager, the app seems to be running in five threads of execution ( :o ).
  • The message pumps of both dialog and OpenGL frame window don't seem to be processing posted, rather than sent, messages, and WM_TIMER is one such message. As I said from the very beginning, the issue requires more attention but so far Charles seems to have eluded it and preferred to get off with this fading splash box example rather than look into the original WM_TIMER issue.
  • There may be definitely a race condition between the dialog's blocking GetMessage() pump and the OpenGL window's apparent non-blocking PeekMessage() pump.
I think this particular app is too complicated to isolate the bug. We should probably roll back to the original WM_TIMER + message box setup and try to examine exactly why it works in 32 bits but fails in 64 bits.

chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #6 on: April 17, 2018, 07:58:40 AM »
Thanxx Mike

maybe something to do with the commonly use handle  hwnd 

if we are allow to have a different variable name for hwnd while inside mysplash.dll  it might
solve the issue? 

maybe something like  hwsplash

Mike Lobanovsky

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #7 on: April 17, 2018, 08:16:12 AM »
Of course you may try and see if it's gonna work for you. (I think it isn't tho)

But either way, it won't give us an answer why posted messages don't work in the original one-window setup of WM_TIMER + message box...

Arnold

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #8 on: April 18, 2018, 02:32:24 AM »
Hi Charles,

I do not know if this will be helpful, but I have started to learn about custom controls:
https://www.codeproject.com/Articles/559385/Custom-Controls-in-Win32-API-The-Basics

As I am only at the beginning I wanted to wait a little bit, but maybe it is already of interest. I try to do the examples using MainWindow of winutil.inc. This is the very first trivial example:

Code: [Select]
'https://www.codeproject.com/Articles/559385/Custom-Controls-in-Win32-API-The-Basics

' application doing actually nothing but creating a main window and
' the custom control as its only child


$ filename "trivial.exe"

'uses rtl32
'uses rtl64

uses WinUtil

#autodim off

% GCL_HBRBACKGROUND = -10
% COLOR_BTNFACE=15
% DT_CENTER=1
% DT_VCENTER=4
% DT_SINGLELINE=32
% SWP_NOZORDER=4
% SIZE_RESTORED=0
% SIZE_MAXIMIZED=2

function RGB(int r, g, b) as int
    return (r + g*256 + b*65536)
end Function



'Window class
string CUSTOM_WC= "CustomControl"

'Register/Unregister the window class
declare sub CustomRegister()
declare sub CustomUnregister()


sys hInstance=inst
sys hwndCustom

% CUSTOM_ID = 100
% MARGIN    =   7


MainWindow 350,250,WS_OVERLAPPEDWINDOW


function WndProc(sys hwnd, Msg, wParam, lParam) as sys callback

    select Msg
       
        case WM_CREATE
            SetWindowText(hwnd, "App Name")
            'Replaces the window-class style bits: color background   
            SetClassLongPtr(hwnd, GCL_HBRBACKGROUND, COLOR_BTNFACE + 1)           

            CustomRegister()
            hwndCustom = CreateWindowEx(0, CUSTOM_WC, null, WS_CHILD | WS_VISIBLE,
                                        0,0,0,0, hwnd, CUSTOM_ID, hInstance, null)

        case WM_CLOSE
            DestroyWindow(hwnd)

        case WM_SIZE
            if wParam = SIZE_MAXIMIZED or wParam = SIZE_RESTORED then
                word cx = LOWORD(lParam)
                word cy = HIWORD(lParam)
                SetWindowPos(hwndCustom, null, MARGIN, MARGIN,
                             cx-2*MARGIN, cy-2*MARGIN, SWP_NOZORDER)
            end if
           
        case WM_DESTROY
            CustomUnregister()
            PostQuitMessage(0)
                   
        case else
            return DefWindowProc(hwnd, Msg, wParam, lParam)

    end select
   
    return 0
end function

=======================================


sub CustomPaint(sys hwnd)
    PAINTSTRUCT ps
    sys hdc
    RECT rect

    GetClientRect(hwnd, &rect)

    hdc = BeginPaint(hwnd, &ps)
    SetTextColor(hdc, RGB(0,0,0))
    SetBkMode(hdc, TRANSPARENT)
    DrawText(hdc, "Hello World!", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER)
    EndPaint(hwnd, &ps)
end sub


function CustomProc(sys hwnd, uint uMsg, sys wParam, lParam) as sys callback
    select uMsg
        case WM_PAINT
            CustomPaint(hwnd)
            return 0
    end select
    return DefWindowProc(hwnd, uMsg, wParam, lParam)
end function


sub CustomRegister()
    WNDCLASS wc

    wc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW
    wc.lpfnWndProc = @CustomProc
    wc.hCursor = LoadCursor(null, IDC_ARROW)
    wc.lpszClassName = strptr CUSTOM_WC
    if not RegisterClass(&wc) then
      mbox "Cannot register Custom Control"
    end if
end sub

sub CustomUnregister()
    UnregisterClass(CUSTOM_WC, null)
end sub
« Last Edit: April 18, 2018, 03:09:15 AM by Arnold »

chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #9 on: April 18, 2018, 05:21:27 AM »
hello Roland

i can't compile your program got an error message at the code

Code: [Select]
SetClassLongPtr(hwnd, GCL_HBRBACKGROUND, COLOR_BTNFACE + 1)


chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #10 on: April 18, 2018, 05:38:25 AM »
i added these code and it can compile but cannot run the exe?

Code: [Select]
uses rtl64
uses WinUtil
! SetClassLongPtr lib "user32.dll" (sys hWnd, int nIndex , sys dwNewLong) as sys



Arnold

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #11 on: April 18, 2018, 05:57:16 AM »
Hi Chris,

my code will run, but your windata.inc, minwin.inc and user.inc are not up-to-date. Try SetClassLong instead. This was suggested by Charles:

http://www.oxygenbasic.org/forum/index.php?topic=1544.msg17694#msg17694

Roland
« Last Edit: April 18, 2018, 06:11:17 AM by Arnold »

chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #12 on: April 18, 2018, 07:01:00 AM »
Thanxx Roland

got it compile with the latest O2 compiler and use SetClassLong

only problem is that i cannot set the background color to other color?

Arnold

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #13 on: April 18, 2018, 07:33:45 AM »
Try e.g.:
...
SetClassLongPtr(hwnd, GCL_HBRBACKGROUND, COLOR_BTNFACE+4)
...
    SetTextColor(hdc, RGB(255,255,255))
...

but these aspects are only peripheral at the moment.

Edit: I was wondering if I can use a normal child window in order to do some actions, or if I must see a splash screen as a customized control. But I do not know enough about OpenGl so I cannot judge what would be the correct way.
« Last Edit: April 18, 2018, 10:52:51 AM by Arnold »

Charles Pegge

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #14 on: April 18, 2018, 02:34:24 PM »
I think I've cracked it. The basic solution is to avoid using PostQuitMessage in OpenGlSceneFrame. Instead using DestroyWindow, then UnregisterClass before returning from the splash call.

I will get some sleep now and do some more testing..