Class: RWin::Dialog

Inherits:
Window
  • Object
show all
Defined in:
ext/rwin/rw_windows.c

Direct Known Subclasses

WR::Dialog

Instance Method Summary collapse

Methods inherited from Window

#ClientToScreen, #DrawMenuBar, #GetWindowLong, #GetWindowRect, #PostMessage, #RegisterHotKey, #ReleaseCapture, #RemoveWindowSubclass, #ScreenToClient, #SendMessage, #SetCapture, #SetFocus, #SetMenu, #SetWindowLong, #SetWindowPos, #SetWindowSubclass, #ShowWindow, #TrackPopupMenu, #UnregisterHotKey, #_hwnd, #alive?, #caption, #caption=, #clientpos, #clientsize, #cursorPos, #event_registered?, #get_msgtranslator, #h, #h=, #idcmd, #idcmd=, #method_missing, #move, new_from_handle, #parent, #parent=, #redraw, #refresh, #register_event, #registered_messages, #resize, #screenpos, #set_accelerator, #set_msgtranslator, #setorder, #unregister_event, #visible, #visible=, #w, #w=, #windowsize, #x, #x=, #y, #y=

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RWin::Window

Instance Method Details

#close(*args) ⇒ Object



1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
# File 'ext/rwin/rw_windows.c', line 1894

static VALUE
rwdialog_close(int argc, VALUE *argv, VALUE self){
    VALUE v_ret;
    RwWindow *rw;
    RwDialog *rd = DATA_PTR(self);
    rw = (RwWindow*)rd;
    RwCheckWindow(rw);
    rb_scan_args(argc, argv, "01", &v_ret);
    if (rd->modal){ //fprintf(stderr, "@%d: v_ret=%lld\n", __LINE__, v_ret); 
//	return rw_call_without_gvl_2(rw->nthread_id, (FARPROC)EndDialog, (ULONG_PTR)rw->hwnd,
//				     (ULONG_PTR)v_ret);
	return EndDialog(rw->hwnd, (INT_PTR)v_ret);
    } else {
	DestroyWindow(((RwWindow*)rd)->hwnd);
	return 0;
    }
}

#create(*args) ⇒ Object



1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
# File 'ext/rwin/rw_windows.c', line 1846

static VALUE
rwdialog_create(int argc, VALUE *argv, VALUE self){
    DLGTEMPLATE *template;
    VALUE v_parent, v_modal, v_param;
    INT_PTR ret;
    HWND hparent = NULL;
    BOOL template_given = FALSE;
    RwDialog *rd = DATA_PTR(self);
    
    if(rb_typeddata_is_kind_of(argv[2], &cstruct_data_type)) {
	VALUE v_template;
	CStructData *cs;
	rb_scan_args(argc, argv, "31", &v_parent, &v_modal, &v_template, &v_param);
	CStruct_Data_Get_Struct(v_template, cs);
	template_given = TRUE;
	template = (DLGTEMPLATE*)(cs->dtstr + cs->dtoffset);
    } else { /* create default template */
	VALUE v_style, v_exstyle;
	rb_scan_args(argc, argv, "23", &v_parent, &v_modal, &v_style, &v_exstyle, &v_param);
	RW_CALLOC(template, sizeof(DLGTEMPLATE) + 4);
	template->style = NIL_P(v_style) ?
	    (WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION | DS_MODALFRAME) : NUM2UINT(v_style);
	template->dwExtendedStyle = NIL_P(v_exstyle) ? 0 : NUM2UINT(v_exstyle);
	rd->param = v_param;
    }
    
    rd->modal = (!NIL_P(v_modal) && v_modal) ? TRUE : FALSE;
    if(!NIL_P(v_parent)){
	RwWindow *rw;
	RwWindow_Data_Get_Struct(v_parent, rw);
	hparent = rw->hwnd;
    }
    if(rd->modal){
	ret = DialogBoxIndirectParam(hInstance, template, hparent, RwDlgProc, self);
	if (ret==-1) rb_raise(rb_eRuntimeError,"create modal dialog failed");
    } else {
	HWND hwnd;
	hwnd = CreateDialogIndirectParam(hInstance, template, hparent, RwDlgProc, self);
	if (!hwnd) rb_raise(rb_eRuntimeError,"create modeless dialog failed");
	ShowWindow(hwnd, TRUE);
	ret = Qnil;
    }
    if(!template_given) {
	free(template);
    }
    return (VALUE)ret;
}

#paramObject



1912
1913
1914
1915
1916
1917
# File 'ext/rwin/rw_windows.c', line 1912

static VALUE
rwdialog_getparam(VALUE self){
    RwDialog *rd = DATA_PTR(self);
    RwCheckWindow((RwWindow*)rd);
    return rd->param;
}