May 11, 2024, 02:35:26 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


borderless edit controls

Started by mrainey, November 15, 2008, 11:51:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mrainey

I found this gem from Paul on the pyxia forum CD.  It's an easy-to-follow road map for creating borderless edit controls.  Unlike other approaches I've seen, there's no need to pass position and size information for each control.  Couldn't be simpler (Paul did all the hard stuff).


DECLARE IMPORT,SetWindowLongA(hwnd as UINT, nIndex as INT, value as UINT),INT
DECLARE IMPORT,GetWindowLongA(hwnd as UINT, nIndex as INT),INT
DECLARE IMPORT,GetDlgItem(hwnd as UINT,id as UINT),UINT
DECLARE IMPORT,SetWindowPos(hwnd as UINT,hwnd2 as UINT,X as INT,Y as INT,cx as INT,cy as INT,flags as UINT),INT
CONST GWL_STYLE = (-16)
CONST GWL_EXSTYLE = (-20)
CONST WS_EX_CLIENTEDGE = 0x200
CONST WS_BORDER = 0x800000
CONST SWP_FRAMECHANGED = &H20
CONST SWP_NOMOVE = &H2
CONST SWP_NOZORDER = &H4
CONST SWP_NOSIZE = &H1
DEF win as WINDOW
DECLARE IMPORT,GetSysColor(nIndex as INT),UINT
OPENWINDOW win,0,0,270,132,@MINBOX,0,"MCH Password",&main
SETWINDOWCOLOR win,GetSysColor(15)
ENABLETABS win, 1
CONTROL win,@STATIC,"Please enter the new MCH password of the day",17,14,240,18,0,1
CONTROL win,@EDIT,"",17,32,228,24,@CTEDITPASS|@TABSTOP,2
CONTROL win,@SYSBUTTON,"Enter",85,64,70,20,@TABSTOP,3
CONTROL win,@SYSBUTTON,"Exit",162,64,70,20,@TABSTOP,4
SETFONT win, "ms sans serif", 8, 400, 0, 1
SETFONT win, "ms sans serif", 8, 400, 0, 2
SETFONT win, "ms sans serif", 8, 400, 0, 3
SETFONT win, "ms sans serif", 8, 400, 0, 4
'play with the styles here
RemoveStyle(GetDlgItem(win.hwnd,2), WS_BORDER)
RedrawBorder(GetDlgItem(win.hwnd,2))
'RemoveExStyle(GetDlgItem(win.hwnd,2), WS_EX_CLIENTEDGE)
'RedrawBorder(GetDlgItem(win.hwnd,2))
WAITUNTIL win = 0
END
'---
REM every time there is a message for our window
REM the operating system will GOSUB here
SUB main
   select @MESSAGE
      case @IDCREATE
         'Sent when the window is first created but before it is displayed
          centerwindow win
       case @IDCLOSEWINDOW
           REM closes the window and sets w1 = 0
           CLOSEWINDOW win
      case @IDCONTROL
         select @CONTROLID
            case 3
               if @NOTIFYCODE = 0 then
                  MESSAGEBOX win, "MCH Password Entered.","MCHPass",@MB_ICONINFORMATION
                  CLOSEWINDOW win
               endif
            case 4
               if @NOTIFYCODE = 0 then
                  'MESSAGEBOX win, "Blah blah","title",@MB_ICONINFORMATION
                  CLOSEWINDOW win
               endif
         endselect
   endselect
RETURN
ENDSUB
SUB AddStyle(hwnd as UINT,style as UINT)
   current = GetWindowLongA(hwnd,GWL_STYLE)
   current |= style
   SetWindowLongA(hwnd,GWL_STYLE,current)
RETURN
ENDSUB
SUB RemoveStyle(hwnd as UINT,style as UINT)
   current = GetWindowLongA(hwnd,GWL_STYLE)
   current &= NOT(style)
   SetWindowLongA(hwnd,GWL_STYLE,current)
RETURN
ENDSUB
SUB AddExStyle(hwnd as UINT,style as UINT)
   current = GetWindowLongA(hwnd,GWL_EXSTYLE)
   current |= style
   SetWindowLongA(hwnd,GWL_EXSTYLE,current)
RETURN
ENDSUB
SUB RemoveExStyle(hwnd as UINT,style as UINT)
   current = GetWindowLongA(hwnd,GWL_EXSTYLE)
   current &= NOT(style)
   SetWindowLongA(hwnd,GWL_EXSTYLE,current)
RETURN
ENDSUB
SUB RedrawBorder(hwnd as UINT)
   'force redraw of the frame
    SetWindowPos(hwnd,NULL,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER)
RETURN
ENDSUB
Software For Metalworking
http://closetolerancesoftware.com

Ionic Wind Support Team

A little bit simpler with Emergence BASIC:


CONST WS_EX_CLIENTEDGE = 0x200
CONST WS_BORDER = 0x800000
DEF win as WINDOW
DECLARE IMPORT,GetSysColor(nIndex as INT),UINT
OPENWINDOW win,0,0,270,132,@MINBOX,0,"MCH Password",&main
SETWINDOWCOLOR win,GetSysColor(15)
ENABLETABS win, 1
CONTROL win,@STATIC,"Please enter the new MCH password of the day",17,14,240,18,0,1
CONTROL win,@EDIT,"",17,32,228,24,@CTEDITPASS|@TABSTOP,2
CONTROL win,@SYSBUTTON,"Enter",85,64,70,20,@TABSTOP,3
CONTROL win,@SYSBUTTON,"Exit",162,64,70,20,@TABSTOP,4
SETFONT win, "ms sans serif", 8, 400, 0, 1
SETFONT win, "ms sans serif", 8, 400, 0, 2
SETFONT win, "ms sans serif", 8, 400, 0, 3
SETFONT win, "ms sans serif", 8, 400, 0, 4
'play with the styles here
ModifyStyle win,0, WS_BORDER,2
RedrawFrame win,2
ModifyExStyle win, 0, WS_EX_CLIENTEDGE,2
RedrawFrame win,2
WAITUNTIL win = 0
END
'---
REM every time there is a message for our window
REM the operating system will GOSUB here
SUB main
   select @MESSAGE
      case @IDCREATE
         'Sent when the window is first created but before it is displayed
          centerwindow win
       case @IDCLOSEWINDOW
           REM closes the window and sets w1 = 0
           CLOSEWINDOW win
      case @IDCONTROL
         select @CONTROLID
            case 3
               if @NOTIFYCODE = 0 then
                  MESSAGEBOX win, "MCH Password Entered.","MCHPass",@MB_ICONINFORMATION
                  CLOSEWINDOW win
               endif
            case 4
               if @NOTIFYCODE = 0 then
                  'MESSAGEBOX win, "Blah blah","title",@MB_ICONINFORMATION
                  CLOSEWINDOW win
               endif
         endselect
   endselect
RETURN
ENDSUB


Ionic Wind Support Team