April 19, 2024, 07:41:38 PM

News:

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


WordPad as Control

Started by Bruce Peaslee, April 16, 2012, 11:01:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

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?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

LarryMc

Only thing I could suggest is Scintilla.

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

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

aurelCB

If you ask me Scintilla is the best solution because have almost everything.
Many ,many examples over net and easy to use and configure.

ZeroDog

April 18, 2012, 01:28:13 AM #4 Last Edit: April 18, 2012, 10:55:34 PM by ZeroDog
<post removed to avoid confusion>

ZeroDog

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.

ZeroDog

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]

Bruce Peaslee

It doesn't appear to work on Windows 7. WordPad opens on its own, but not as a control.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

ZeroDog

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.