News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

User Defined Controls...

Started by xandaz, September 17, 2011, 09:47:54 PM

Previous topic - Next topic

xandaz

    I'm was looking at RESED controls that you can add to a dialog and found that there is a UDC ( User defined control) Does anyone know anything about this? What is it?
Can someone one show me a user defined control? Or are these just owner drawn controls?
   Thanks

Tedd

I'm guessing it's simply for a generic control statement.

All controls can be specified in the form of CONTROL text, id, class, style, x, y, width, height, ex-style. The main ones used have a shorthand form, e.g. PUSHBUTTON, EDITTEXT, BITMAP, etc; but this doesn't cover every possible control, and couldn't deal with future or user-defined controls. So you can specify any type with the CONTROL statement (as long as you can provide a class name.)
No snowflake in an avalanche feels responsible.

xandaz

   oh Thanks Tedd. Seems like a reasonable explanation. ty

jj2007

Quote from: Tedd on September 18, 2011, 12:18:58 PM
So you can specify any type with the CONTROL statement (as long as you can provide a class name.)

Tedd,

How would you create an arbitrary self-defined control? RegisterClassEx as usual, then CreateWindowEx in the main window's WM_CREATE handler? I have tampered around a bit, but it first gave me error 1407, class not found (but RegisterClassEx returns non-zero), now CreateWindowEx returns zero but GetLastError says there is no error ::)

MichaelW

I tried Scintilla as a user-defined control with ResEd and everything worked as expected. Basically, I inserted a UDC control in a dialog and then in the control properties changed the class from UDCCLASS to Scintilla, and with the addition of the #include "resource.h" statement ended up with a working resource definition:

#include "resource.h"
#define IDD_DLG1 1000
#define IDC_UDC1 1001

IDD_DLG1 DIALOGEX 10,10,150,100
CAPTION "IDD_DLG"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW
BEGIN
  CONTROL "IDC_UDC",IDC_UDC1,"Scintilla",WS_CHILDWINDOW|WS_VISIBLE,12,9,126,81
END


That when compiled and converted to an object module, and linked with the object module for this source:

;==============================================================================
    include \masm32\include\masm32rt.inc
;==============================================================================
    .data
      hInstance dd  0
    .code
;==============================================================================

DialogProc proc hwndDlg:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD

    SWITCH uMsg

      CASE WM_CLOSE

        invoke EndDialog, hwndDlg, 0

    ENDSW

    xor eax, eax
    ret

DialogProc endp

;==============================================================================
start:
;==============================================================================

    invoke LoadLibrary, chr$("SciLexer.dll")

    invoke GetModuleHandle, NULL
    mov hInstance, eax

    invoke DialogBoxParam, hInstance, 1000, 0, ADDR DialogProc, 0

    invoke ExitProcess, eax

;==============================================================================
end start


Produced a working EXE.

eschew obfuscation