IonicWind Software

IWBasic => GUI Central => Topic started by: Bruce Peaslee on April 16, 2012, 11:01:18 PM

Title: WordPad as Control
Post by: Bruce Peaslee on April 16, 2012, 11:01:18 PM
I am looking for a way to get WordPad functionality (text color, styles, lists, etc) in a control in a dialog. One way would be to control WordPad through code, but I don't know how to do that, if it can be done. Another way would be to make a new control based on RichEdit, but that to me is a huge undertaking.

Any suggestions?
Title: Re: WordPad as Control
Post by: LarryMc on April 16, 2012, 11:27:41 PM
Only thing I could suggest is Scintilla.

I know it has a lot of capabilities I haven't even looked into.

LarryMc
Title: Re: WordPad as Control
Post by: Bruce Peaslee on April 17, 2012, 10:04:31 AM
Quote from: LarryMc on April 16, 2012, 11:27:41 PM
Only thing I could suggest is Scintilla.

I will look at it. At least the price is right.

Thanks.
Title: Re: WordPad as Control
Post by: aurelCB on April 17, 2012, 03:05:35 PM
If you ask me Scintilla is the best solution because have almost everything.
Many ,many examples over net and easy to use and configure.
Title: Re: WordPad as Control
Post by: ZeroDog on April 18, 2012, 01:28:13 AM
<post removed to avoid confusion>
Title: Re: WordPad as Control
Post by: ZeroDog on April 18, 2012, 05:48:17 AM
Hmmm... maybe it wasn't as easy and uncomplicated as I first thought?  Seems like it has some quirks to it... for example, if you load a text file, it will reposition the window offset to the actual parent window location.

Oh well, maybe I'll toy around with this idea some more after I recharge the old grey matter.
Title: Re: WordPad as Control
Post by: ZeroDog on April 18, 2012, 10:56:50 PM
Okay, after a good night's sleep, I reworked the code, so that it should work properly in all aspects now:

['embedding wordpad into an iwbasic window - ZeroDog

declare import, SetParent(hwndchild as int, hwndnewparent as int),int
declare import, ShellExecuteA(hwnd as int, lpoperation as string, lpfile as string, lpparameters as string, lpdirectory as string, nshowcmd as int),int
declare import, FindWindowA(lpclassname as string, lpwindowname as string),int
declare import, ScreenToClient(hwnd as int, lppoint as point),int

def win,wordpadwin:window
def sl,st,sx,sy:int
def wordpadpoint:point

openwindow win, 0,0,640,480, @caption|@size|@maxbox|@minbox|@sysmenu, 0, "Embedding WordPad into IWBasic Windows", &winproc

shellexecutea(win.hwnd, "", "WordPad.exe", "", "", @swhide)
while wordpadwin.hwnd=0
wordpadwin.hwnd=findwindowa("WordPadClass", "WordPad")
endwhile

setparent(wordpadwin.hwnd, win.hwnd)
getclientsize win,sl,st,sx,sy
setsize wordpadwin,0,0,sx,sy
modifystyle wordpadwin,0x40000000|0x80000000, @caption|@size|@maxbox|@minbox|@sysmenu
redrawframe wordpadwin

run=1
waituntil run=0
closewindow win
end

sub winproc(),int
select @class
case @idcreate
centerwindow win
case @idsize
getclientsize win,sl,st,sx,sy
setsize wordpadwin,0,0,sx,sy
case @idclosewindow
run=0
default
if run=1
getsize wordpadwin,sl,st,sx,sy
wordpadpoint.x=sl:wordpadpoint.y=st
screentoclient(win.hwnd, wordpadpoint)
if wordpadpoint.x>0 or wordpadpoint.y>0
getclientsize win,sl,st,sx,sy
setsize wordpadwin,0,0,sx,sy
endif
endif
endselect
return 0
endsub
/code]
Title: Re: WordPad as Control
Post by: Bruce Peaslee on April 19, 2012, 03:15:21 PM
It doesn't appear to work on Windows 7. WordPad opens on its own, but not as a control.
Title: Re: WordPad as Control
Post by: ZeroDog on April 19, 2012, 09:09:38 PM
I suspect it's in the following code that's the problem on W7:


shellexecutea(win.hwnd, "", "WordPad.exe", "", "", @swhide)
while wordpadwin.hwnd=0
wordpadwin.hwnd=findwindowa("WordPadClass", "WordPad")
endwhile


WordPad may have changed slightly since XP.  In XP, the class is "WordPadClass", and it initially opens up with the title "WordPad" before it changes the title to "Document - WordPad".   Try finding out what the class is for WordPad in W7, and what the title is when it initially opens.  I use a program called "Spy & Capure Version 2.70" to find stuff like the window class of an application's windows are.

You're not actually supposed to be able to do what I was doing either, so MicroSoft may have put in countermeasures for this on windows versions after XP.