I am using the IUP library to create an MDI frame and MDI child window. I get the window and child window appearing. When I try to maximize the child window the program GPF. The crash is the standard Win XP GPF.
It crashes when you click the maximize button or when you use:
Code: Select all
iupsetattribute(chld, "PLACEMENT", "MAXIMIZED")
The code is built off of demonstration code posted here.
These are the most relevant code lines (The whole code posted at the end :
Code: Select all
sub ScintillaTest()
dim as Ihandle ptr dlg, chld
dim as Ihandle ptr sci
Dim As Ihandle Ptr file_Menu
Dim As IHandle Ptr subMenu
Dim As Ihandle Ptr itm_File
Dim As Ihandle Ptr itm_New
Dim As Ihandle Ptr itm_Open
Dim As Ihandle Ptr itm_Save
Dim As Ihandle Ptr itm_SaveAs
Dim As Ihandle Ptr itm_Close
Dim As Ihandle Ptr itm_Exit
Dim As Ihandle Ptr mnu
IupScintillaOpen()
'' Creates an instance of the Scintilla control
sci = IupScintilla()
'' IupSetAttribute(sci, "VISIBLECOLUMNS", "80")
'' IupSetAttribute(sci, "VISIBLELINES", "40")
''IupSetAttribute(sci, "SCROLLBAR", "NO")
IupSetAttribute(sci, "BORDER", "YES")
IupSetAttribute(sci, "EXPAND", "Yes")
IupSetCallback(sci, "MARGINCLICK_CB", cast(icallback,@marginclick_cb))
IupSetCallback(sci, "HOTSPOTCLICK_CB", cast(icallback,@hotspotclick_cb))
'' IupSetCallback(sci, "BUTTON_CB", @button_cb)
'' IupSetCallback(sci, "MOTION_CB", @motion_cb)
IupSetCallback(sci, "CARET_CB", cast(icallback,@caret_cb))
IupSetCallback(sci, "VALUECHANGED_CB", cast(icallback,@valuechanged_cb))
IupSetCallback(sci, "ACTION", cast(icallback,@action_cb))
Dim iframe As ihandle Ptr
Dim icanvas As ihandle Ptr
icanvas = IupCanvas(NIL)
iupsetattribute(icanvas, "EXPAND", "YES")
iupsetattribute(icanvas, "MDICLIENT", "YES")
iframe = IupFrame(icanvas)
dlg = IupDialog(iframe)
iupsetattribute(dlg,"MDIFRAME", "YES")
iupsetattribute(dlg, "TITLE", "Holy Cow")
iupsetattribute(dlg, "SIZE", "HALFxHALF")
IupSetAttribute(dlg, "TITLE", "IupScintilla")
IupSetAttribute(dlg, "RASTERSIZE", "700x500")
IupSetAttribute(dlg, "MARGIN", "10x10")
'IupSetAttribute(dlg, "TITLE", "IupScintilla")
'chld = IupDialog(IupVbox(sci, NIL))
IupShow(dlg)
Dim itxt As ihandle Ptr
itxt = IupText(NIL)
iupsetattribute(itxt, "EXPAND", "YES")
iupsetattribute(itxt, "MULTILINE", "YES")
chld = IupDialog(itxt)
iupsetattribute(chld, "TITLE", "Mdi 1")
iupsetattribute(chld, "SIZE", "200x150")
iupsetattribute(chld, "MDICHILD", "YES")
'''''' iupsetattribute(chld, "PLACEMENT", "MAXIMIZED")
iupsethandle("mainform", dlg)
'''''
iupsetattribute(chld, "PARENTDIALOG", "mainform")
IupShow(chld)
'''''set_attribs(sci)
End sub
Here is the entire program:
Code: Select all
#include "crt/stdlib.bi"
#include "crt/stdio.bi"
#include "crt/string.bi"
#ifndef NIL
#define NIL cast(any ptr,0)
#endif
#define IUP_IGNORE -1
#define IUP_DEFAULT -2
#define IUP_CLOSE -3
#define IUP_CONTINUE -4
type Ihandle as any
type Icallback as function cdecl (byval as Ihandle ptr) as integer
Dim Shared IupVersion As Function Cdecl () As ZString Ptr
dim shared IupOpen as function cdecl (byval as integer ptr, byval as zstring ptr ptr ptr) as integer
dim shared IupSetCallback as function cdecl (byval as ihandle ptr, byval as zstring ptr, byval as icallback) as icallback
dim shared IupMainLoop as sub cdecl ()
dim shared IupClose as sub cdecl ()
dim shared IupGetAttributeId as function cdecl (byval as Ihandle ptr, byval as zstring ptr, byval as integer) as zstring ptr
dim shared IupGetAttribute as function cdecl (byval as Ihandle ptr, byval as zstring ptr) as zstring ptr
dim shared IupSetAttribute as sub cdecl (byval as Ihandle ptr, byval as zstring ptr, byval as zstring ptr)
dim shared IupSetfAttribute as sub cdecl (byval as Ihandle ptr, byval as zstring ptr, byval as zstring ptr, ...)
dim shared IupShow as function cdecl (byval as Ihandle ptr) as integer
dim shared IupScintillaOpen as sub cdecl ()
dim shared IupScintilla as function cdecl () as Ihandle ptr
dim shared IupDialog as function cdecl (byval as Ihandle ptr) as ihandle Ptr
' these are the functions we add to create the menu
Dim Shared IupItem As Function Cdecl (ByVal As ZString Ptr, ByVal As ZString Ptr) As Ihandle Ptr
Dim Shared IupMenu As Function Cdecl (ByVal As Ihandle Ptr, ...) As Ihandle Ptr
Dim Shared IupSubMenu As Function Cdecl (ByVal As ZString Ptr, ByVal As Ihandle Ptr) As Ihandle Ptr
Dim Shared IupSeparator As Function Cdecl () As Ihandle Ptr
Dim Shared IupSetHandle As function Cdecl (ByVal As ZString Ptr, ByVal As Ihandle Ptr) As Ihandle ptr
' We dont use this one yet. But later might need it.
Dim Shared IupSetAttributeHandle As Sub Cdecl (ByVal As ihandle Ptr, ByVal As ZString Ptr, ByVal As Ihandle Ptr)
Dim Shared IupCanvas As Function Cdecl(ByVal As ZString Ptr) As Ihandle Ptr
Dim Shared IupFrame As Function Cdecl(ByVal As Ihandle Ptr) As Ihandle Ptr
Dim Shared IupText As Function Cdecl(ByVal As ZString Ptr) As Ihandle Ptr
dim Shared IupVbox as function cdecl (byval as Ihandle ptr, ...) as ihandle ptr
dim shared sampleCode as string * 1708 = _
!"enum FB_TKCLASS\n" +_
!" FB_TKCLASS_IDENTIFIER\n" +_
!" FB_TKCLASS_KEYWORD\n" +_
!" FB_TKCLASS_QUIRKWD\n" +_
!" FB_TKCLASS_NUMLITERAL\n" +_
!" FB_TKCLASS_STRLITERAL\n" +_
!" FB_TKCLASS_OPERATOR\n" +_
!" FB_TKCLASS_DELIMITER\n" +_
!" FB_TKCLASS_UNKNOWN\n" +_
!"end enum\n" +_
!"\n" +_
!"\'\':::::\n" +_
!"sub symbSetDefType _\n" +_
!" ( _\n" +_
!" byval ichar as integer, _\n" +_
!" byval echar as integer, _\n" +_
!" byval dtype as integer _\n" +_
!" )\n" +_
!"\n" +_
!" dim as integer i = any\n" +_
!"\n" +_
!" if( ichar < asc(\"A\") ) then\n" +_
!" ichar = asc(\"A\")\n" +_
!" elseif( ichar > asc(\"_\") ) then\n" +_
!" ichar = asc(\"_\")\n" +_
!" end if\n" +_
!"\n" +_
!" if( echar < asc(\"A\") ) then\n" +_
!" echar = asc(\"A\")\n" +_
!" elseif( echar > asc(\"_\") ) then\n" +_
!" echar = asc(\"_\")\n" +_
!" end if\n" +_
!"\n" +_
!" if( ichar > echar ) then\n" +_
!" swap ichar, echar\n" +_
!" end if\n" +_
!"\n" +_
!" for i = ichar to echar\n" +_
!" deftypeTB(i - asc(\"A\")) = dtype\n" +_
!" next\n" +_
!"\n" +_
!"end sub\n" +_
!"\n" +_
!"\'\' Recalculate the length, to be used after the symbol's type was set/changed\n" +_
!"sub symbRecalcLen( byval sym as FBSYMBOL ptr )\n" +_
!" if( sym->class = FB_SYMBCLASS_PARAM ) then\n" +_
!" sym->lgt = symbCalcParamLen( sym->typ, sym->subtype, sym->param.mode )\n" +_
!" else\n" +_
!" sym->lgt = symbCalcLen( sym->typ, sym->subtype )\n" +_
!" end if\n" +_
!"end sub\n" +_
!"\n" +_
!"dim shared s as string\n" +_
!"s = \"hello world\"\n" +_
!"type simple_type\n" +_
!" dim field1 as integer\n" +_
!" dim field2 as integer\n" +_
!"end type\n"
function marginclick_cb cdecl(byval self as Ihandle ptr, byval margin as integer, byval line_ as integer, byval status as zstring ptr) as integer
Print "hello"
printf(!"MARGINCLICK_CB(Margin: %d, Line: %d, Status:%s)\n", margin, line_, status)
printf(!"Fold Level = %s\n", IupGetAttributeId(self, "FOLDLEVEL", line_))
IupSetfAttribute(self, "FOLDTOGGLE", "%d", line_)
return IUP_DEFAULT
end function
function hotspotclick_cb cdecl(byval self as Ihandle ptr, byval pos_ as integer, byval line_ as integer, byval col as integer, byval status as zstring ptr) as integer
dim text as zstring ptr = IupGetAttributeId(self, "LINE", line_)
printf(!"HOTSPOTCLICK_CB (Pos: %d, Line: %d, Col: %d, Status:%s)\n", pos_, line_, col, status)
printf(!" line text = %s\n", text)
return IUP_DEFAULT
end function
function button_cb cdecl(byval self as Ihandle ptr, byval button as integer, byval pressed as integer, byval x as integer, byval y as integer, byval status as zstring ptr) as integer
printf(!"BUTTON_CB = button: %d, pressed: %d, x: %d, y: %d, status: %s\n", button, pressed, x, y, status)
return IUP_DEFAULT
end function
function motion_cb cdecl(byval self as Ihandle ptr, byval x as integer, byval y as integer, byval status as zstring ptr) as integer
printf(!"MOTION_CB = x: %d, y: %d, status: %s\n", x, y, status)
return IUP_DEFAULT
end function
function caret_cb cdecl (byval self as Ihandle ptr, byval lin as integer, byval col as integer, byval pos_ as integer) as integer
printf(!"CARET_CB = lin: %d, col: %d, pos_: %d\n", lin, col, pos_)
return IUP_DEFAULT
end function
function valuechanged_cb cdecl(byval self as Ihandle ptr) as integer
printf(!"VALUECHANGED_CB\n")
return IUP_DEFAULT
end function
function action_cb cdecl (byval self as Ihandle ptr, byval insert as integer, byval pos_ as integer, byval length as integer, byval text as zstring ptr) as integer
printf(!"ACTION = insert: %d, pos_: %d, lenght:%d, text: %s\n", insert, pos_, length, text)
return IUP_IGNORE
end function
sub set_attribs (byval sci as Ihandle ptr)
IupSetAttribute(sci, "CLEARALL", "")
IupSetAttribute(sci, "LEXERLANGUAGE", "vb")
IupSetAttribute(sci, "KEYWORDS1", "sub function declare dim end type union as ptr enum "_
"if elseif then select case default break goto return for while do continue sizeof typeof new delete property namespace operator this cast using andalso orelse xor or and not cdecl byval byref ")
IupSetAttribute(sci,"KEYWORDS2","integer long ulong ulongint longint string zstring wstring short ushort ubyte double single unsigned signed")
IupSetAttribute(sci, "STYLEFONT32", "Consolas")
IupSetAttribute(sci, "STYLEFONTSIZE32", "11")
IupSetAttribute(sci, "STYLECLEARALL", "Yes") /' sets all styles to have the same attributes as 32 '/
IupSetAttribute(sci, "STYLEFGCOLOR1", "0 128 0") '' 1-BASIC comment
IupSetAttribute(sci, "STYLEFGCOLOR2", "0 128 0") '' 2-BASIC comment line
IupSetAttribute(sci, "STYLEFGCOLOR4", "139 0 139") '' 4-String
IupSetAttribute(sci, "STYLEFGCOLOR5", "0 128 128") ''
IupSetAttribute(sci, "STYLEFGCOLOR6", "255 20 147") ''6-Operators
IupSetAttribute(sci, "STYLEFGCOLOR7", "0 0 0") '' 7-Character
IupSetAttribute(sci, "STYLEFGCOLOR9", "205 149 12") '' 9-Preprocessor block
IupSetAttribute(sci, "STYLEFGCOLOR10", "0 197 205") '' 10-Keywords1
IupSetAttribute(sci, "STYLEFGCOLOR11", "0 255 0") '' 11-Keywords2
IupSetAttribute(sci, "STYLEBOLD10", "YES")
IupSetAttribute(sci, "STYLEHOTSPOT4", "YES")
IupSetAttribute(sci, "STYLEHOTSPOT11", "YES")
IupSetAttribute(sci, "INSERT0", sampleCode)
IupSetAttribute(sci, "MARGINWIDTH0", "50")
if (1) then
IupSetAttribute(sci, "PROPERTY", "fold=1")
IupSetAttribute(sci, "PROPERTY", "fold.compact=0")
IupSetAttribute(sci, "PROPERTY", "fold.comment=1")
IupSetAttribute(sci, "PROPERTY", "fold.preprocessor=1")
IupSetAttribute(sci, "MARGINWIDTH1", "20")
IupSetAttribute(sci, "MARGINTYPE1", "SYMBOL")
IupSetAttribute(sci, "MARGINMASKFOLDERS1", "Yes")
IupSetAttribute(sci, "MARKERDEFINE", "FOLDER=PLUS")
IupSetAttribute(sci, "MARKERDEFINE", "FOLDEROPEN=MINUS")
IupSetAttribute(sci, "MARKERDEFINE", "FOLDEREND=EMPTY")
IupSetAttribute(sci, "MARKERDEFINE", "FOLDERMIDTAIL=EMPTY")
IupSetAttribute(sci, "MARKERDEFINE", "FOLDEROPENMID=EMPTY")
IupSetAttribute(sci, "MARKERDEFINE", "FOLDERSUB=EMPTY")
IupSetAttribute(sci, "MARKERDEFINE", "FOLDERTAIL=EMPTY")
IupSetAttribute(sci, "FOLDFLAGS", "LINEAFTER_CONTRACTED")
IupSetAttribute(sci, "MARGINSENSITIVE1", "YES")
end if
printf(!"Number of chars in this text: %s\n", IupGetAttribute(sci, "COUNT"))
printf(!"Number of lines in this text: %s\n", IupGetAttribute(sci, "LINECOUNT"))
printf(!"%s\n", IupGetAttribute(sci, "LINEVALUE"))
end sub
sub ScintillaTest()
dim as Ihandle ptr dlg, chld
dim as Ihandle ptr sci
Dim As Ihandle Ptr file_Menu
Dim As IHandle Ptr subMenu
Dim As Ihandle Ptr itm_File
Dim As Ihandle Ptr itm_New
Dim As Ihandle Ptr itm_Open
Dim As Ihandle Ptr itm_Save
Dim As Ihandle Ptr itm_SaveAs
Dim As Ihandle Ptr itm_Close
Dim As Ihandle Ptr itm_Exit
Dim As Ihandle Ptr mnu
IupScintillaOpen()
'' Creates an instance of the Scintilla control
sci = IupScintilla()
'' IupSetAttribute(sci, "VISIBLECOLUMNS", "80")
'' IupSetAttribute(sci, "VISIBLELINES", "40")
''IupSetAttribute(sci, "SCROLLBAR", "NO")
IupSetAttribute(sci, "BORDER", "YES")
IupSetAttribute(sci, "EXPAND", "Yes")
IupSetCallback(sci, "MARGINCLICK_CB", cast(icallback,@marginclick_cb))
IupSetCallback(sci, "HOTSPOTCLICK_CB", cast(icallback,@hotspotclick_cb))
'' IupSetCallback(sci, "BUTTON_CB", @button_cb)
'' IupSetCallback(sci, "MOTION_CB", @motion_cb)
IupSetCallback(sci, "CARET_CB", cast(icallback,@caret_cb))
IupSetCallback(sci, "VALUECHANGED_CB", cast(icallback,@valuechanged_cb))
IupSetCallback(sci, "ACTION", cast(icallback,@action_cb))
Dim iframe As ihandle Ptr
Dim icanvas As ihandle Ptr
icanvas = IupCanvas(NIL)
iupsetattribute(icanvas, "EXPAND", "YES")
iupsetattribute(icanvas, "MDICLIENT", "YES")
iframe = IupFrame(icanvas)
dlg = IupDialog(iframe)
iupsetattribute(dlg,"MDIFRAME", "YES")
iupsetattribute(dlg, "TITLE", "Holy Cow")
iupsetattribute(dlg, "SIZE", "HALFxHALF")
IupSetAttribute(dlg, "TITLE", "IupScintilla")
IupSetAttribute(dlg, "RASTERSIZE", "700x500")
IupSetAttribute(dlg, "MARGIN", "10x10")
'IupSetAttribute(dlg, "TITLE", "IupScintilla")
'chld = IupDialog(IupVbox(sci, NIL))
IupShow(dlg)
Dim itxt As ihandle Ptr
itxt = IupText(NIL)
iupsetattribute(itxt, "EXPAND", "YES")
iupsetattribute(itxt, "MULTILINE", "YES")
chld = IupDialog(itxt)
iupsetattribute(chld, "TITLE", "Mdi 1")
iupsetattribute(chld, "SIZE", "200x150")
iupsetattribute(chld, "MDICHILD", "YES")
'''''' iupsetattribute(chld, "PLACEMENT", "MAXIMIZED")
iupsethandle("mainform", dlg)
'''''
iupsetattribute(chld, "PARENTDIALOG", "mainform")
'ScreenRes 800,600,32
'Print "version"
'Print( *IupVersion())
'Sleep
IupShow(chld)
'''''set_attribs(sci)
End sub
sub mymain()
var iup = DyLibLoad("iup.dll")
if (iup = NIL) then
print "error loading iup"
return
end If
var scintilla = DylibLoad("iup_scintilla.dll")
if (scintilla = NIL) then
print "error loading scintilla"
dylibfree(iup)
Return
end if
IupVersion = DylibSymbol(iup, "IupVersion")
IupOpen = DylibSymbol(iup,"IupOpen")
IupSetCallback = DyLibSymbol(iup,"IupSetCallback")
IupMainLoop = DyLibSymbol(iup,"IupMainLoop")
IupClose = DyLibSymbol(iup,"IupClose")
IupSetAttribute = DyLibSymbol(iup,"IupSetAttribute")
IupShow = DyLibSymbol(iup,"IupShow")
IupScintilla = DyLibSymbol(scintilla,"IupScintilla")
IupScintillaOpen = DyLibSymbol(scintilla,"IupScintillaOpen")
IupSetCallback = DyLibSymbol(iup,"IupSetCallback")
IupSetfAttribute = DyLibSymbol(iup,"IupSetfAttribute")
IupDialog = DyLibSymbol(iup,"IupDialog")
IupGetAttributeId = DyLibSymbol(iup,"IupGetAttributeId")
IupGetAttribute = DyLibSymbol(iup,"IupGetAttribute")
IupVbox = DyLibSymbol(iup,"IupVbox")
IupFrame = DylibSymbol(iup, "IupFrame")
IupCanvas = DylibSymbol(iup, "IupCanvas")
IupText = DylibSymbol(iup, "IupText")
IupItem = DylibSymbol(iup, "IupItem")
IupMenu = DylibSymbol(iup, "IupMenu")
IupSubMenu = DylibSymbol(iup, "IupSubmenu")
IupSeparator = DylibSymbol(iup, "IupSeparator")
IupSetHandle = DylibSymbol(iup, "IupSetHandle")
IupOpen(NIL,NIL)
ScintillaTest()
IupMainLoop()
IupClose()
DyLibFree(iup)
DyLibFree(scintilla)
return
end Sub
mymain()
End