hello coders,
first sorry about my bad English
every time i call GetDC the program will crash
same if i use the DC from desktop (0=NULL)
thank you for any hint
(how to use code tags in this forum?)
Joshy
[code]onst PFD_TYPE_RGBA = 0
const PFD_TYPE_COLORINDEX = 1
const PFD_MAIN_PLANE = 0
const PFD_OVERLAY_PLANE = 1
const PFD_UNDERLAY_PLANE = -1
const PFD_DOUBLEBUFFER = 1
const PFD_STEREO = 2
const PFD_DRAW_TO_WINDOW = 4
const PFD_DRAW_TO_BITMAP = 8
const PFD_SUPPORT_GDI = 16
const PFD_SUPPORT_OPENGL = 32
const PFD_GENERIC_FORMAT = 64
const PFD_NEED_PALETTE = 128
const PFD_NEED_SYSTEM_PALETTE = 256
const PFD_SWAP_EXCHANGE = 512
const PFD_SWAP_COPY = 1024
const PFD_SWAP_LAYER_BUFFERS = 2048
const PFD_GENERIC_ACCELERATED = 4096
const PFD_DEPTH_DONTCARE = &H20000000
const PFD_DOUBLEBUFFER_DONTCARE = &H40000000
const PFD_STEREO_DONTCARE = &H80000000
const pSize =1
const pVersion=3
const pFlags=5
const pPixelType=9
const pColorBits=10
const pRedBits=11
const pRedShift=12
const pGreenBits=13
const pGreenShift=14
const pBlueBits=15
const pBlueShift=16
const pAlphaBits=17
const pAlphaShift=18
const pAccumBits=19
const pAccumRedBits=20
const pAccumGreenBits=21
const pAccumBlueBits=22
const pAccumAlphaBits=23
const pDepthBits=24
const pStencilBits=25
const pAuxBuffers=26
const pLayerType=27
const pReserved=28
const pLayerMask=29
const pVisibleMask=33
const pDamageMask=36
function MakePixelFormat (Bits as integer, Depth as integer, Stencil as integer,Accum as integer ) as string
dim s as string
s=string$(0,40 )
mid$ s,pSize=mkw$(40 )
mid$ s,pVersion=mkw$(1)
mid$ s,pFlags=mki$(PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER)
mid$ s,pPixelType=chr$(PFD_TYPE_RGBA)
mid$ s,pColorBits=chr$(Bits)
mid$ s,pDepthBits=chr$(Depth)
mid$ s,pStencilBits=chr$(Stencil)
mid$ s,pAccumBits=chr$(Accum)
result=s
end function
declare GetDC as "GetDC" of "gdi32.dll"
hWND as integer
result as integer
end declare
declare ReleaseDC as "ReleaseDC" of "gdi32.dll"
hWND as integer
hDC as integer
result as integer
end declare
declare ChoosePixelFormat as "ChoosePixelFormat" of "gdi32.dll"
hDC as integer
ppfd as string byaddress
result as integer
end declare
declare SetPixelFormat as "SetPixelFormat" of "gdi32.dll"
hDC as integer
iFormat as integer
ppfd as string byaddress
result as integer
end declare
declare wglCreateContext as "wglCreateContext" of "opengl32.dll"
hDC as INTEGER
result as INTEGER
end declare
declare wglDeleteContext as "wglDeleteContext" of "opengl32.dll"
hRC as INTEGER
result as INTEGER
end declare
declare wglMakeCurrent as "wglMakeCurrent" of "opengl32.dll"
hdc as integer
hrc as integer
result as integer
end declare
type RENDERDEVICE
dim PixelFormatDesc as string
dim hWnd as integer
dim hDC as integer
dim hRc as integer
dim iFormat as integer
end type
object window as FORM
Width=640
Height=480
Caption = "OpenGL with FNX Basic"
end object
`````LOADLIBRARY "gdi32.dll"
`````LOADLIBRARY "opengl32.dll"
dim MyDevice as RENDERDEVICE
Window.Show
print "create()"
Window.Show
MyDevice.hWND=Window.Hwnd
if MyDevice.hWND=0 then
ShowMessage "error: Create() hWND=NULL !"
end if
print "GetDC(" + str$(MyDevice.hWnd) + ")"
GetDC.hWnd=MyDevice.hWnd
GetDC
MyDevice.hDC=GetDC.Result
print "after GetDC"
if MyDevice.hDC=0 then
ShowMessage "error: GetDC() !"
end if
print "MakePixelFormat"
MyDevice.PixelFormatDesc=MakePixelFormat(16,16,0,0)
print "ChoosePixelFormat()"
ChoosePixelFormat.hDC=MyDevice.hDC
ChoosePixelFormat.pPFD=MyDevice.PixelFormatDesc
ChoosePixelFormat
MyDevice.iFormat=ChoosePixelFormat.Result
if MyDevice.iFormat=0 then
ShowMessage "error: ChoosePixelFormat() !"
ReleaseDC.hWnd=MyDevice.hWnd
ReleaseDC.hDC=MyDevice.hDC
ReleaseDC
MyDevice.hDC=0
MyDevice.hWND=0
end if
print "ok"
do
doevents
loop until window.visible=false
sleep(10000)
end[/code]
GetDC will crash
GetDC will crash
I don`t know much about gdi but i give it a try.
As far as i can see GetDC is a function of user32.dll (http://msdn.microsoft.com/en-us/library/dd144871(VS.85).aspx)
In my gdi32.dll i only see GetDeviceCaps not GetDC (http://msdn.microsoft.com/en-us/library/dd144877(VS.85).aspx).
It look to me you are using the wrong function/dll combination.
I hope this helps a little.
As far as i can see GetDC is a function of user32.dll (http://msdn.microsoft.com/en-us/library/dd144871(VS.85).aspx)
In my gdi32.dll i only see GetDeviceCaps not GetDC (http://msdn.microsoft.com/en-us/library/dd144877(VS.85).aspx).
It look to me you are using the wrong function/dll combination.
I hope this helps a little.
-
- Posts: 3
- Joined: Tue Nov 08, 2005 3:00 pm
GetDC will crash
[quote author=fred link=1262218622/0#1 date=1262253778]I hope this helps a little.[/quote]
you made my day ;-)
i wonder me why the byte code runtime engine don`t print a message about the missing/wrong DLL import.
But ok i will change my mistake.
thank you
Joshy
you made my day ;-)
i wonder me why the byte code runtime engine don`t print a message about the missing/wrong DLL import.
But ok i will change my mistake.
thank you
Joshy
-
- Posts: 3
- Joined: Tue Nov 08, 2005 3:00 pm
GetDC will crash
now i know why my mistakes happened
CreateDC, CreateCompatibleDC and DeleteDC are from gdi32.dll
but GetDC and ReleaseDC are a part of user32.dll
Joshy
(sorry about my bad English)
CreateDC, CreateCompatibleDC and DeleteDC are from gdi32.dll
but GetDC and ReleaseDC are a part of user32.dll
Joshy
(sorry about my bad English)
GetDC will crash
Glad i could help :)
I agree it would be nice to have an error with a non existing name, but when the declaration is good you will never get an error from it.
As long as we understand each other our English is good enough else we should ask to make it more clear :)
I agree it would be nice to have an error with a non existing name, but when the declaration is good you will never get an error from it.
As long as we understand each other our English is good enough else we should ask to make it more clear :)