From: richard.townsendrose on 22 Jun 2010 10:49 Hi All I have a datadialog window with some text and a few buttons and a single Multiline edit. In the postinit, i load the thing up, and i want to highlight some text if its there ... at the moment it doesn't even set focus to the edit, let alone highlight the located text - it DOES locate it ok. richard METHOD PostInit(oWindow,iCtlID,oServer,uExtra) CLASS SetKeyWords LOCAL n:=0 AS DWORD SELF:oDCJobNo:Value:=uExtra[1] SELF:oDCSubjRef:Value:=uExtra[2] SELF:cKeyWord:=AllTrim(uExtra[5]) SELF:cFile:=SysObject():GetParam(AltReports) + AllTrim(uExtra[1]) + '_' + AllTrim(uExtra[2]) IF uExtra[3] == CONTACT_REASON cFile:=cFile + '_CONTACT.txt' ELSEIF uExtra[3] == FORM_TYPE cFile:=cFile + '_' + uExtra[4] + '_GENDOC.txt' ELSE SELF:EndWindow() ENDIF IF File(cFile) SELF:lNew:=FALSE SELF:oDCKeyFile:Value:=MemoRead(cFile) // highlight keyword if found IF Instr(SELF:cKeyWord + ' ', SELF:oDCKeyFile:Value + ' ') n:=At(SELF:cKeyWord + ' ', SELF:oDCKeyFile:Value + ' ' ) SELF:oDCKeyFile:Selection:=Selection{n+1,SLen(SELF:cKeyWord)} ENDIF ELSE SELF:lNew:=TRUE ENDIF SELF:oDCKeyFile:SetFocus() RETURN NIL
From: Mathias on 23 Jun 2010 04:48 Hi Richard, try letting the MLE be the first control in the control order. The first control should recieve focus. If this fails as well you could do a PostMessage(self:handle(),WM_USER, 0,0L) in the postinit method and then listen to that message in a Dispatch method and do the processing there. The problem you are experiencing here is that in the postinit method the dialog has not been diaplayed yet and no focus has been set. You try to set the focus, but focus is later set to the first control in the Show() method. method Dispatch(oEvent) class MyDataDialog do case case oEvent:message == WM_USER // Do your stuff endcase return super:Dispatch(oEvent) Mathias On 22 Juni, 16:49, "richard.townsendrose" <richard.townsendr...(a)googlemail.com> wrote: > Hi All > > I have a datadialog window with some text and a few buttons and a > single Multiline edit. > > In the postinit, i load the thing up, and i want to highlight some > text if its there ... > > at the moment it doesn't even set focus to the edit, let alone > highlight the located text - it DOES locate it ok. > > richard > > METHOD PostInit(oWindow,iCtlID,oServer,uExtra) CLASS SetKeyWords > LOCAL n:=0 AS DWORD > > SELF:oDCJobNo:Value:=uExtra[1] > SELF:oDCSubjRef:Value:=uExtra[2] > SELF:cKeyWord:=AllTrim(uExtra[5]) > > SELF:cFile:=SysObject():GetParam(AltReports) + AllTrim(uExtra[1]) + > '_' + AllTrim(uExtra[2]) > IF uExtra[3] == CONTACT_REASON > cFile:=cFile + '_CONTACT.txt' > ELSEIF uExtra[3] == FORM_TYPE > cFile:=cFile + '_' + uExtra[4] + '_GENDOC.txt' > ELSE > SELF:EndWindow() > ENDIF > > IF File(cFile) > SELF:lNew:=FALSE > SELF:oDCKeyFile:Value:=MemoRead(cFile) > // highlight keyword if found > IF Instr(SELF:cKeyWord + ' ', SELF:oDCKeyFile:Value + ' ') > n:=At(SELF:cKeyWord + ' ', SELF:oDCKeyFile:Value + ' ' ) > SELF:oDCKeyFile:Selection:=Selection{n+1,SLen(SELF:cKeyWord)} > ENDIF > ELSE > SELF:lNew:=TRUE > ENDIF > > SELF:oDCKeyFile:SetFocus() > > RETURN NIL
From: Karl Faller on 23 Jun 2010 05:47 richard, why not set the focus in the Show() ?? Karl >Hi All > >I have a datadialog window with some text and a few buttons and a >single Multiline edit. > >In the postinit, i load the thing up, and i want to highlight some >text if its there ... > >at the moment it doesn't even set focus to the edit, let alone >highlight the located text - it DOES locate it ok. > >richard > > >METHOD PostInit(oWindow,iCtlID,oServer,uExtra) CLASS SetKeyWords > LOCAL n:=0 AS DWORD > > SELF:oDCJobNo:Value:=uExtra[1] > SELF:oDCSubjRef:Value:=uExtra[2] > SELF:cKeyWord:=AllTrim(uExtra[5]) > > SELF:cFile:=SysObject():GetParam(AltReports) + AllTrim(uExtra[1]) + >'_' + AllTrim(uExtra[2]) > IF uExtra[3] == CONTACT_REASON > cFile:=cFile + '_CONTACT.txt' > ELSEIF uExtra[3] == FORM_TYPE > cFile:=cFile + '_' + uExtra[4] + '_GENDOC.txt' > ELSE > SELF:EndWindow() > ENDIF > > IF File(cFile) > SELF:lNew:=FALSE > SELF:oDCKeyFile:Value:=MemoRead(cFile) > // highlight keyword if found > IF Instr(SELF:cKeyWord + ' ', SELF:oDCKeyFile:Value + ' ') > n:=At(SELF:cKeyWord + ' ', SELF:oDCKeyFile:Value + ' ' ) > SELF:oDCKeyFile:Selection:=Selection{n+1,SLen(SELF:cKeyWord)} > ENDIF > ELSE > SELF:lNew:=TRUE > ENDIF > > SELF:oDCKeyFile:SetFocus() > >RETURN NIL
From: richard.townsendrose on 23 Jun 2010 07:14 Mathias, Karl thanks for the thoughts - as usual these point the brain, and some testing shows: a) order of controls making it first control is fine ... but as a recent post said ... the whole mle is then selected. making it second control after another static control is the same as making it first control making the first control a button sets the focus to the button. b) using show() METHOD Show() CLASS SetKeyWords SUPER:Show() SELF:oDCKeyFile:SetFocus() SELF:oDCKeyFile:Selection:=Selection{0,0} RETURN NIL once the call to super show() is made -- then set focus ... doesn't work even putting super:show() last has no effect - no focus c) my solution in the postinit() SELF:RegisterTimer(1,TRUE) METHOD Timer() CLASS SetKeyWords SELF:oDCKeyFile:SetFocus() SELF:oDCKeyFile:Selection:=Selection{0,0} RETURN NIL this works a treat ... and so i can now highlight the keyword if it exists ... another day of learning .. see my post on saving a bitmap ... richard
From: Mathias on 24 Jun 2010 00:59 The datadialog is modal by default. That means that the application does not leave the show method until you close the datadialog. This means that you are setting focus om the mle just as it closes. /Mathias > b) using show() > > METHOD Show() CLASS SetKeyWords > > SUPER:Show() > > SELF:oDCKeyFile:SetFocus() > SELF:oDCKeyFile:Selection:=Selection{0,0} > > RETURN NIL
|
Next
|
Last
Pages: 1 2 Prev: Creating BITMAP File from a DIBIMage Next: Printer does not eject the current page |