post two:
the code example for this edit window is too long (character length is limited to 20.000 characters)..
'OPENGL /WINDOWS API Example
' Revised 9 July 2010
' Charles Pegge
' Frank BrĂ¼bach, 17.April.2013
$ filename "t.exe"
'#file "t.exe"
'#include "../../inc/RTL32.inc"
'#include "../../inc/RTL64.inc"
#include "../../inc/minwin.inc"
'include "ViewPorts_2openGL.inc"
%Buttoni=1001
%Buttoni2=1002
s=error()
'
if s then
print s
end
end if
'--------------------------------------------
' $ filename "dragNdrop_Window1x.exe"
'#include "../../inc/RTL32.inc"
'#include "../../inc/RTL64.inc"
' #include "../../inc/MinWin.inc"
' #lookahead ' for procedures
' s=error()
'
' if s then
' print s
' end
' end if
'%WM_DROPFILES = &H0233???
'%WM_DROPFILES = &H233
% WM_DROPFILES = 0x0233
Dim myDroppedFiles(10) As String
Declare Function DragQueryFile Lib "shell32" Alias "DragQueryFileA" ( _
ByVal wHandle As sys, _
ByVal NumFiles As sys, _
ByVal NameBuffer As sys, _
ByVal BufferLen As Long) As sys
Declare Sub DragFinish Lib "shell32" Alias "DragFinish" (ByVal wHandle As Long)
DECLARE SUB DragAcceptFiles LIB "shell32.DLL" ALIAS "DragAcceptFiles" ( _
BYVAL hWnd AS SYS _ ' __in HWND hWnd
, BYVAL fAccept AS LONG _ ' __in BOOL fAccept
) ' void
'=========
'MAIN CODE
'=========
dim cmdline as asciiz ptr, inst as sys
&cmdline=GetCommandLine
inst=GetModuleHandle 0
'
'WINDOWS START
'=============
'
'WinMainer inst,0,cmdline,SW_NORMAL
'end
'--------------------------------------------------------------------
Function WinMainer(sys inst, prevInst, asciiz*cmdline, sys show) as sys
'====================================================================
WndClass wc
MSG wm
sys hwnd, wwd, wht, wtx, wty, tax
wc.style = CS_HREDRAW or CS_VREDRAW
wc.lpfnWndProc = @WndProx
wc.cbClsExtra =0
wc.cbWndExtra =0
wc.hInstance =inst
wc.hIcon=LoadIcon 0, IDI_APPLICATION
wc.hCursor=LoadCursor 0,IDC_ARROW
wc.hbrBackground = GetStockObject WHITE_BRUSH
wc.lpszMenuName =null
wc.lpszClassName = strptr "Demo"
RegisterClass (@wc)
Wwd = 420 : Wht = 300
Tax = GetSystemMetrics SM_CXSCREEN
Wtx = (Tax - Wwd) /2
Tax = GetSystemMetrics SM_CYSCREEN
Wty = (Tax - Wht) /2
hwnd = CreateWindowEx 0,wc.lpszClassName,"drag and Drop Test + sdk win api!",WS_OVERLAPPEDWINDOW,300+Wtx,Wty,Wwd,Wht,0,0,inst,0
ShowWindow hwnd,SW_SHOW
UpdateWindow hwnd
'---------------------------- this line is IMPORTANT ! ------
DragAcceptFiles(hwnd, TRUE)
'---------------------------- this line is IMPORTANT ! ------
'
sys bRet
'
do while bRet := GetMessage (@wm, 0, 0, 0)
if bRet = -1 then
'show an error message
else
TranslateMessage @wm
DispatchMessage @wm
end if
wend
End Function
Function Alternative_GetDropFiles(ByVal hDropParam As SYS) As String
Local sDropFiles As String, sFile As String, i As Long
for i = 1 To DragQueryFile(hDropParam, &HFFFFFFFF&, "", 0)-1
sFile = space(DragQueryFile(hDropParam, i, "", 0)+1)
'sFile = SPACE$(DragQueryFile(hDropParam, i, "", 0)+1)
'DragQueryFile(hDropParam, i, ByVal StrPtr(sFile), Len(sFile))
DragQueryFile(hDropParam, i, StrPtr(sFile), Len(sFile))
sFile = LEFT$(sFile, Len(sFile)-1)
' RIGHT(sFile,4) doesn't exists
If Ucase(LEFT$(sFile, 4)) = ".LNK" Then sFile = "" 'GetLinkInfo(sFile, 1)
sDropFiles = sDropFiles + sFile + "|"
next i
FUNCTION = RTrim(sDropFiles) ', "|")
End Function
dim as rect crect 'for WndProc and TimerProc
'--------------------------------------------------------------
function WndProx ( sys hWnd, wMsg, wParam, lparam ) as sys callback
'==============================================================
static as sys hdc
static as String txt
static as PaintStruct Paintst
dim myButton,hFont,inst as sys
'==========
select wMsg
'==========
'--------------
case WM_CREATE
'==============
mbox "here it comes second win api :)"
myButton = CreateWindowEx(0, _
"Button", _
"push me2!", _
%WS_CHILD OR %WS_VISIBLE OR _
%BS_PUSHBUTTON OR %BS_FLAT, _
22, 20, _
90, 44, _
hWnd, %Buttoni2, _
inst, 0)
SendMessage myButton, WM_SETFONT, hFont, TRUE '1
Case WM_DROPFILES
mbox "here I am after dropfiled"
'
'test one
'
pDrop = wparam 'CBWPARAM
sFiles = Alternative_GetDropFiles(pDrop)
' Free handle...
DragFinish(wparam)
'
'test two
'
If Alternative_GetDropFiles(wparam) Then "" 'myListDroppedFiles(1)
DragFinish (wparam)
mbox "test: here's to drag something"
'MessageBox hwnd, "Files dropped onto the dialog: " + $CRLF + $CRLF + sFiles, "frankos_dragDrop_test", %MB_ICONINFORMATION
'--------------
case WM_COMMAND
'==============
if wparam = %Buttoni2 then
print "test another button"
end if
'--------------
case WM_DESTROY
'===============
PostQuitMessage 0
DragAcceptFiles(hwnd, TRUE)
'------------
case WM_PAINT
'============
'TEXT
'http://msdn.microsoft.com/en-us/library/dd144821(v=VS.85).aspx
'DRAWING AND PAINTING
'http://msdn.microsoft.com/en-us/library/dd162760(v=VS.85).aspx
GetClientRect hWnd,&cRect
hDC=BeginPaint hWnd,&Paintst
'style
'0x20 DT_SINGLELINE
'0x04 DT_VCENTER
'0x01 DT_CENTER
'0x25
SetBkColor hdc,yellow
SetTextColor hdc,red
DrawText hDC,"Hello Drag'n'Drop Oxygen_World!",-1,&cRect,0x25
EndPaint hWnd,&Paintst
'--------------
case WM_KEYDOWN
'==============
'============
Select wParam
'============
Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
End Select
'--------
case else
'========
function=DefWindowProc hWnd,wMsg,wParam,lParam
end select
end function ' WndProc
'print "test ok"
'--------------------------------------------
/*
Window size wWidth wHeight
Active view:
0 = none
1 = upper left
2 = upper right
3 = lower left
4 = lower right
*/
'OPENGL HEADERS
'==============
#define WINGDIAPI
#define APIENTRY
#define const
typedef word wchar_t
typedef sys ptrdiff_t
'
includepath "..\..\inc\glo2\"
library "opengl32.dll"
include once "gl\gl.h"
'include once "gl\glext.h"
library "glu32.dll"
include once "gl\glu.h"
library ""
'
'
include once "gl\wgl.inc"
dim as sys a
dim gmf(256) AS GLYPHMETRICSFLOAT
dim as quad
'
'TIMING
'
grtic1,grtic2,freq
dim as double
'
'TIMING
'
fps,grlap
dim as sys
'
'STATE VARIABLES
'
refresh,bselect,kselect,keyd,cha,ReqShutDown,
bLeft,bMid,bRight,bWheel,
wWidth,wHeight,
'
'GL CONTEXT
'
hDC,hRC,
'
shadows,shadowable,
antialias, multisampling,
nPixelFormat,ReqNewMode,arbMultisampleFormat,
arbMultisampleSupported,
'
'TIMING
'
timerval, doredraw,
'
'POSITIONAL
'
xpos, ypos,
sposx,sposy,mposx,mposy,eposx,eposy,
'
'Rotation around each axis
'
rot_x, rot_y, rot_z,
active_view
'====================================================================
' DrawTorus() - Draw a solid torus (use a display list for the model)
'====================================================================
sub DrawTorus
finit
static as double
twopi = pi()*2,
torus_major = 1.5,
torus_minor = 0.5,
torus_major_res= 32,
torus_minor_res= 32
static as sys
torus_list, i,j,k
static as single
a, b, s, t, x, y, z, nx, ny, nz, gscale,tmc,tmd,tme
if not torus_list
'
'Record the Torus plot list
'--------------------------
'
torus_list = glGenLists 1
glNewList( torus_list, GL_COMPILE_AND_EXECUTE )
'
'Draw the torus
'
for i = 0 to TORUS_MINOR_RES-1
'
glBegin GL_QUAD_STRIP
'
for j = 0 to TORUS_MAJOR_RES
'
for k = 1 to 0 STEP -1
'
s = mod( i+k,TORUS_MINOR_RES + 0.5)
t = mod(j,TORUS_MAJOR_RES)
'
'CALCULATE POINT ON SURFACE
'--------------------------
'
tmd=s*twopi/TORUS_MINOR_RES
tme=t*twopi/TORUS_MAJOR_RES
tmc=TORUS_MAJOR+TORUS_MINOR * cos tmd
'
x = tmc * cos tme
y = TORUS_MINOR * sin tmd
z = tmc * sin tme
'
'CALCULATE SURFACE NORMAL
'------------------------
'
a=TORUS_MAJOR * cos tme
nx = x - a
ny = y
a=TORUS_MAJOR * sin tme
nz = z - a
'
'SCALING OF NORMALS
'
gscale = recip ( SQR( nx*nx + ny*ny + nz*nz ))
nx*=gscale
ny*=gscale
nz*=gscale
'
glNormal3f nx, ny, nz
glVertex3f x, y, z
'
next
'
next
'
glEnd()
'
next
'
glEndList()
'
else
'
'Playback displaylist
'
glCallList( torus_list )
end if
end sub
''================================================
'' DrawScene() - Draw the scene (a rotating torus)
''================================================
sub DrawScene
static as single,
model_diffuse(4) => (1.0, 0.8, 0.0, 1.0),
model_specular(4) => (0.0, 0.0, 1.0, 1.0),
model_shininess=0.1
glPushMatrix
'Rotate the object
glRotatef rot_x*0.5, 1.0, 0.0, 0.0
glRotatef rot_y*0.5, 0.0, 1.0, 0.0
glRotatef rot_z*0.5, 0.0, 0.0, 1.0
'Set model color (used for orthogonal views, lighting disabled)
'
glColor4fv model_diffuse
'Set model material (used for perspective view, lighting enabled)
'
glMaterialfv GL_FRONT, GL_DIFFUSE, model_diffuse
glMaterialfv GL_FRONT, GL_SPECULAR, model_specular
glMaterialf GL_FRONT, GL_SHININESS, model_shininess
'
DrawTorus
glPopMatrix
end sub
'============================================================
' DrawBorder() - Draw a 2D border (used for orthogonal views)
'============================================================
sub DrawBorder( byval gscale as single, st as sys )
dim as single x,y
glPushMatrix
'Setup modelview matrix (flat XY view)
'
glLoadIdentity
gluLookAt _
0.0, 0.0, 1.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
'We don't want to update the Z-buffer
'
glDepthMask GL_FALSE
'Set color
'---------
glDisable GL_LIGHTING
glColor3f 0.7, 0.7, 0.4
glBegin GL_LINES
dim h as sys
'h=gsteps*0.5
h=st*0.5
x = gscale * h
y = gscale * h
'Horizontal lines
'----------------
glVertex3f -x, -y, 0.0
glVertex3f x, -y, 0.0
glVertex3f -x, y, 0.0
glVertex3f x, y, 0.0
'Vertical lines
glVertex3f -x, -y, 0.0
glVertex3f -x, y, 0.0
glVertex3f x, -y, 0.0
glVertex3f x, y, 0.0
glEnd
'Enable Z-buffer writing again
'
glDepthMask GL_TRUE
glPopMatrix
end sub
'========================================================
' DrawGrid() - Draw a 2D grid (used for orthogonal views)
'========================================================
sub DrawGrid( BYVAL gscale AS SINGLE, BYVAL gsteps AS INTEGER )
dim as sys i
dim as single x,y
glPushMatrix
'Set background color
'
glClearColor 0.15, 0.15, 0.3, 0.0
glClear GL_COLOR_BUFFER_BIT
'Setup modelview matrix (flat XY view)
'
glLoadIdentity
gluLookAt _
0.0, 0.0, 1.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
'
'We don't want to update the Z-buffer
'
glDepthMask GL_FALSE
'
'Set grid color
glDisable GL_LIGHTING
glColor3f 0.0, 0.5, 0.5
glBegin GL_LINES
dim g,h as sys
g=gsteps
h=g*0.5
'' Horizontal lines
x = gscale * h
y = (-gscale) * h
'
for i = 0 to g
glVertex3f -x, y, 0.0
glVertex3f x, y, 0.0
y+=gscale
next
'' Vertical lines
x = -gscale * h
y = gscale * h
'
for i = 0 to g
glVertex3f x, -y, 0.0
glVertex3f x, y, 0.0
x+=gscale
next
glEnd
'Enable Z-buffer writing again
'
glDepthMask GL_TRUE
glPopMatrix
end sub
sys e
'part two as followed...