int iupwinCreateWindow(Ihandle* ih, LPCTSTR lpClassName, DWORD dwExStyle, DWORD dwStyle, void* clientdata) { ih->serial = iupDialogGetChildId(ih); ih->handle = iupwinCreateWindowEx(iupChildTreeGetNativeParentHandle(ih), lpClassName, dwExStyle, dwStyle, ih->serial, clientdata); if (!ih->handle) return 0; /* associate HWND with Ihandle*, all Win32 controls must call this. */ iupwinHandleAdd(ih, ih->handle); /* replace the WinProc to handle base callbacks */ iupwinChangeWndProc(ih, iupwinBaseWndProc); return 1; }
static HWND winTabCreatePageWindow(Ihandle* ih) { HWND hWnd; DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS, dwExStyle = 0; iupwinGetNativeParentStyle(ih, &dwExStyle, &dwStyle); hWnd = CreateWindowEx(dwExStyle, "IupTabsPage", NULL, dwStyle, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, ih->handle, NULL, iupwin_hinstance, NULL); iupwinHandleAdd(ih, hWnd); return hWnd; }
int iupdrvBaseSetTipAttrib(Ihandle* ih, const char* value) { HWND tips_hwnd = (HWND)iupAttribGet(ih, "_IUPWIN_TIPSWIN"); if (!tips_hwnd) { tips_hwnd = winTipsCreate(ih->handle); iupAttribSetStr(ih, "_IUPWIN_TIPSWIN", (char*)tips_hwnd); iupwinHandleAdd(ih, tips_hwnd); } if (value) winTipsSendMessage(ih, tips_hwnd, TTM_ADDTOOL); else winTipsSendMessage(ih, tips_hwnd, TTM_DELTOOL); return 1; }
int iupdrvBaseSetTipAttrib(Ihandle* ih, const char* value) { HWND tips_hwnd = (HWND)iupAttribGet(ih, "_IUPWIN_TIPSWIN"); if (!tips_hwnd) { tips_hwnd = winTipsCreate(ih->handle); iupwinHandleAdd(ih, tips_hwnd); iupAttribSet(ih, "_IUPWIN_TIPSWIN", (char*)tips_hwnd); } if (value) { int tool_exists = (int)SendMessage(tips_hwnd, TTM_GETCURRENTTOOL, 0, 0); if (!tool_exists) winTipsSendMessage(ih, tips_hwnd, TTM_ADDTOOL); } else winTipsSendMessage(ih, tips_hwnd, TTM_DELTOOL); return 1; }
static int winDialogMapMethod(Ihandle* ih) { InativeHandle* native_parent; DWORD dwStyle = WS_CLIPSIBLINGS, dwExStyle = 0; int has_titlebar = 0, has_border = 0; char* classname = "IupDialog"; char* title = iupAttribGet(ih, "TITLE"); if (title) has_titlebar = 1; if (iupAttribGetBoolean(ih, "RESIZE")) { dwStyle |= WS_THICKFRAME; has_border = 1; } else iupAttribSetStr(ih, "MAXBOX", "NO"); if (iupAttribGetBoolean(ih, "MENUBOX")) { dwStyle |= WS_SYSMENU; has_titlebar = 1; } if (iupAttribGetBoolean(ih, "MAXBOX")) { dwStyle |= WS_MAXIMIZEBOX; has_titlebar = 1; } if (iupAttribGetBoolean(ih, "MINBOX")) { dwStyle |= WS_MINIMIZEBOX; has_titlebar = 1; } if (iupAttribGetBoolean(ih, "BORDER") || has_titlebar) has_border = 1; if (iupAttribGetBoolean(ih, "MDICHILD")) { Ihandle *client; /* must have a parent dialog (the mdi frame) */ Ihandle* parent = IupGetAttributeHandle(ih, "PARENTDIALOG"); if (!parent || !parent->handle) return IUP_ERROR; /* set when the mdi client is mapped */ client = (Ihandle*)iupAttribGet(parent, "MDICLIENT_HANDLE"); if (!client) return IUP_ERROR; /* store the mdi client handle in each mdi child also */ iupAttribSetStr(ih, "MDICLIENT_HANDLE", (char*)client); classname = "IupDialogMDIChild"; /* The actual parent is the mdi client */ native_parent = client->handle; dwStyle |= WS_CHILD; if (has_titlebar) dwStyle |= WS_CAPTION; else if (has_border) dwStyle |= WS_BORDER; if (!IupGetName(ih)) iupAttribSetHandleName(ih); } else { native_parent = iupDialogGetNativeParent(ih); if (native_parent) { dwStyle |= WS_POPUP; if (has_titlebar) dwStyle |= WS_CAPTION; else if (has_border) dwStyle |= WS_BORDER; } else { if (has_titlebar) { dwStyle |= WS_OVERLAPPED; } else { if (has_border) dwStyle |= WS_POPUP | WS_BORDER; else dwStyle |= WS_POPUP; dwExStyle |= WS_EX_NOACTIVATE; /* this will hide it from the taskbar */ } } if (iupAttribGetBoolean(ih, "MDIFRAME")) { COLORREF color = GetSysColor(COLOR_BTNFACE); iupAttribSetStrf(ih, "_IUPWIN_BACKGROUND_COLOR", "%d %d %d", (int)GetRValue(color), (int)GetGValue(color), (int)GetBValue(color)); classname = "IupDialogMDIFrame"; } } if (iupAttribGetBoolean(ih, "TOOLBOX") && native_parent) dwExStyle |= WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE; if (iupAttribGetBoolean(ih, "DIALOGFRAME") && native_parent) dwExStyle |= WS_EX_DLGMODALFRAME; /* this will hide the MENUBOX but not the close button */ iupwinGetNativeParentStyle(ih, &dwExStyle, &dwStyle); if (iupAttribGetBoolean(ih, "HELPBUTTON")) dwExStyle |= WS_EX_CONTEXTHELP; if (iupAttribGetBoolean(ih, "CONTROL") && native_parent) { /* TODO: this were used by LuaCom to create embeded controls, don't know if it is still working */ dwStyle = WS_CHILD | WS_TABSTOP | WS_CLIPCHILDREN; classname = "IupDialogControl"; } /* CreateWindowEx will send WM_GETMINMAXINFO before Ihandle is associated with HWND */ if (iupAttribGet(ih, "MINSIZE") || iupAttribGet(ih, "MAXSIZE")) winMinMaxHandle = ih; /* size will be updated in IupRefresh -> winDialogLayoutUpdate */ /* position will be updated in iupDialogShowXY */ if (iupAttribGetBoolean(ih, "MDICHILD")) ih->handle = CreateMDIWindow(classname, title, /* title */ dwStyle, /* style */ 0, /* x-position */ 0, /* y-position */ 100, /* horizontal size - set this to avoid size calculation problems */ 100, /* vertical size */ native_parent, /* owner window */ iupwin_hinstance, /* instance of app. */ 0); /* no creation parameters */ else ih->handle = CreateWindowEx(dwExStyle, /* extended styles */ classname, /* class */ title, /* title */ dwStyle, /* style */ 0, /* x-position */ 0, /* y-position */ 100, /* horizontal size - set this to avoid size calculation problems */ 100, /* vertical size */ native_parent, /* owner window */ (HMENU)0, /* Menu or child-window identifier */ iupwin_hinstance, /* instance of app. */ NULL); /* no creation parameters */ if (!ih->handle) return IUP_ERROR; /* associate HWND with Ihandle*, all Win32 controls must call this. */ iupwinHandleAdd(ih, ih->handle); if (iupStrEqual(classname, "IupDialogMDIChild")) /* hides the mdi child */ ShowWindow(ih->handle, SW_HIDE); /* configure for DROP of files */ if (IupGetCallback(ih, "DROPFILES_CB")) iupAttribSetStr(ih, "DROPFILESTARGET", "YES"); /* Reset attributes handled during creation that */ /* also can be changed later, and can be consulted from the native system. */ iupAttribSetStr(ih, "TITLE", NULL); /* Ignore VISIBLE before mapping */ iupAttribSetStr(ih, "VISIBLE", NULL); /* Set the default CmdShow for ShowWindow */ ih->data->cmd_show = SW_SHOWNORMAL; if (iupAttribGetBoolean(ih, "MDICHILD")) winDialogMDIRefreshMenu(ih); return IUP_NOERROR; }
static int winCanvasMapMethod(Ihandle* ih) { CLIENTCREATESTRUCT clientstruct; void *clientdata = NULL; char *classname; DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS, dwExStyle = 0; if (!ih->parent) return IUP_ERROR; if (ih->iclass->is_interactive) { if (iupAttribGetBoolean(ih, "CANFOCUS")) dwStyle |= WS_TABSTOP; } if (ih->firstchild) /* can be a container */ iupwinGetNativeParentStyle(ih, &dwExStyle, &dwStyle); if (iupAttribGetBoolean(ih, "BORDER")) dwStyle |= WS_BORDER; ih->data->sb = iupBaseGetScrollbar(ih); if (ih->data->sb & IUP_SB_HORIZ) dwStyle |= WS_HSCROLL; if (ih->data->sb & IUP_SB_VERT) dwStyle |= WS_VSCROLL; if (iupAttribGetBoolean(ih, "MDICLIENT")) { /* creating a MDI Client that will be inside the MDI Frame, it will work as parent of all MDI children */ Ihandle *winmenu = IupGetAttributeHandle(ih, "MDIMENU"); classname = "mdiclient"; dwStyle = WS_CHILD|WS_CLIPCHILDREN|WS_VSCROLL|WS_HSCROLL|MDIS_ALLCHILDSTYLES; dwExStyle = WS_EX_CLIENTEDGE; iupAttribSetStr(ih, "BORDER", "NO"); iupAttribSetStr(IupGetDialog(ih), "MDICLIENT_HANDLE", (char*)ih); clientdata = &clientstruct; clientstruct.hWindowMenu = winmenu? winmenu->handle: NULL; /* The system increments the identifier for each additional MDI child window the application creates, and reassigns identifiers when the application destroys a window to keep the range of identifiers contiguous. */ clientstruct.idFirstChild = IUP_MDI_FIRSTCHILD; } else classname = "IupCanvas"; ih->serial = iupDialogGetChildId(ih); ih->handle = CreateWindowEx(dwExStyle,/* extended style */ classname, /* window class */ NULL, /* title */ dwStyle, /* window style */ 0, /* x-position */ 0, /* y-position */ 10, /* default width to avoid 0 */ 10, /* default height to avoid 0 */ iupChildTreeGetNativeParentHandle(ih), /* window parent */ (HMENU)ih->serial, /* child identifier */ iupwin_hinstance, /* instance of app. */ clientdata); if (!ih->handle) return IUP_ERROR; /* associate HWND with Ihandle*, all Win32 controls must call this. */ iupwinHandleAdd(ih, ih->handle); if (iupAttribGetBoolean(ih, "MDICLIENT")) iupwinChangeProc(ih, iupwinBaseWinProc); else IupSetCallback(ih, "_IUPWIN_OLDPROC_CB", (Icallback)DefWindowProc); IupSetCallback(ih, "_IUPWIN_CTRLPROC_CB", (Icallback)winCanvasProc); /* configure for DROP of files */ if (IupGetCallback(ih, "DROPFILES_CB")) iupAttribSetStr(ih, "DROPFILESTARGET", "YES"); return IUP_NOERROR; }
static int winListMapMethod(Ihandle* ih) { char* class_name; DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS, dwExStyle = WS_EX_CLIENTEDGE; if (!ih->parent) return IUP_ERROR; if (ih->data->is_dropdown || ih->data->has_editbox) { class_name = "COMBOBOX"; dwStyle |= CBS_NOINTEGRALHEIGHT; if (ih->data->is_dropdown) dwStyle |= WS_VSCROLL|WS_HSCROLL; else if (ih->data->sb) { dwStyle |= WS_VSCROLL|WS_HSCROLL; if (!iupAttribGetBoolean(ih, "AUTOHIDE")) dwStyle |= CBS_DISABLENOSCROLL; } if (ih->data->has_editbox) { dwStyle |= CBS_AUTOHSCROLL; if (ih->data->is_dropdown) dwStyle |= CBS_DROPDOWN; /* hidden-list+edit */ else dwStyle |= CBS_SIMPLE; /* visible-list+edit */ } else dwStyle |= CBS_DROPDOWNLIST; /* hidden-list */ if (iupAttribGetBoolean(ih, "SORT")) dwStyle |= CBS_SORT; } else { class_name = "LISTBOX"; dwStyle |= LBS_NOINTEGRALHEIGHT|LBS_NOTIFY; if (ih->data->is_multiple) dwStyle |= LBS_EXTENDEDSEL; if (ih->data->sb) { dwStyle |= WS_VSCROLL|WS_HSCROLL; if (!iupAttribGetBoolean(ih, "AUTOHIDE")) dwStyle |= LBS_DISABLENOSCROLL; } if (iupAttribGetBoolean(ih, "SORT")) dwStyle |= LBS_SORT; } if (iupAttribGetBoolean(ih, "CANFOCUS")) dwStyle |= WS_TABSTOP; if (!iupwinCreateWindowEx(ih, class_name, dwExStyle, dwStyle)) return IUP_ERROR; /* Custom Procedure */ IupSetCallback(ih, "_IUPWIN_CTRLPROC_CB", (Icallback)winListProc); /* Process background color */ IupSetCallback(ih, "_IUPWIN_CTLCOLOR_CB", (Icallback)winListCtlColor); /* Process WM_COMMAND */ IupSetCallback(ih, "_IUPWIN_COMMAND_CB", (Icallback)winListWmCommand); if (ih->data->is_dropdown || ih->data->has_editbox) { COMBOBOXINFO boxinfo; ZeroMemory(&boxinfo, sizeof(COMBOBOXINFO)); boxinfo.cbSize = sizeof(COMBOBOXINFO); GetComboBoxInfo(ih->handle, &boxinfo); iupwinHandleAdd(ih, boxinfo.hwndList); iupAttribSetStr(ih, "_IUPWIN_LISTBOX", (char*)boxinfo.hwndList); /* subclass the list box. */ IupSetCallback(ih, "_IUPWIN_LISTOLDPROC_CB", (Icallback)GetWindowLongPtr(boxinfo.hwndList, GWLP_WNDPROC)); SetWindowLongPtr(boxinfo.hwndList, GWLP_WNDPROC, (LONG_PTR)winListComboListWinProc); if (ih->data->has_editbox) { iupwinHandleAdd(ih, boxinfo.hwndItem); iupAttribSetStr(ih, "_IUPWIN_EDITBOX", (char*)boxinfo.hwndItem); /* subclass the edit box. */ IupSetCallback(ih, "_IUPWIN_EDITOLDPROC_CB", (Icallback)GetWindowLongPtr(boxinfo.hwndItem, GWLP_WNDPROC)); SetWindowLongPtr(boxinfo.hwndItem, GWLP_WNDPROC, (LONG_PTR)winListEditWinProc); /* set defaults */ SendMessage(ih->handle, CB_LIMITTEXT, 0, 0L); } } /* configure for DRAG&DROP */ if (IupGetCallback(ih, "DROPFILES_CB")) iupAttribSetStr(ih, "DRAGDROP", "YES"); IupSetCallback(ih, "_IUP_XY2POS_CB", (Icallback)winListConvertXYToPos); iupListSetInitialItems(ih); return IUP_NOERROR; }