April 19, 2024, 05:37:20 AM

News:

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


Notification / messages

Started by Andy, June 19, 2020, 12:03:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Well, I can see some sort of finishing line to my editor program now, but as always I have another question...

I read somewhere about message queues - let me explain a little more...

The colouring of text is working well, and on the whole you don't see the program colouring the text on screen, however you do see it briefly when pressing the page up / down keys.

It's not a major thing but can I / is there a way to detect these two key presses before the rich edit control actually scrolls a page up / down?

If so, I would like to try colouring the next / previous page before it appears.

Any one any ideas please?

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Can anyone help with this please?

Thanks,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

You could give it a try by subclassing the richedit and catching WM_KEYDOWN. If it works -> perform the colouring and handle the scrolling by yourself and return 0 (zero) to cancel the message.

Andy

Fasecero,

What a hero you are!

It just shows that you are never too old to learn something.

My rich edit control was already sub classed, and I was already detecting WM_KEYDOWN, just didn't know you could cancel a control's message (once sub classed by returning zero for wParam) like this:

if wParam = 34 'Page down
   int StoreTopLine = SendMessage(rHandle,EM_GETFIRSTVISIBLELINE,0,0)
   ScrollDownPage() '<------- My sub to colour the next set of lines (not visable yet)
   int NewTopLine = StoreTopLine + 29
   setcontroltext(w1,EDIT_1,ltrim$(str$(NewTopLine))) '<----- This moves the scroll position to the line I want
   Offset = SendMessage(rHandle,EM_LINEINDEX,(sRange.Low / 16) + 28,0)
   SendMessage(rHandle,EM_SETSEL,Offset,Offset)
   setfocus w1,1
   RETURN CallWindowProcA(GetPropA(hwnd,"edit_handler"),hwnd,uMsg,0,lParam) '<----- This line here ***
endif

Thank you so much, in just a couple of hours, I have managed to sort out all the colouring issues!

Andy.
 :)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

Nice. The standard way to cancel a message is to avoid CallWindowProcA, so just call

RETURN 0
instead of

RETURN CallWindowProcA(GetPropA(hwnd,"edit_handler"),hwnd,uMsg,0,lParam) '<----- This line here ***

Brian

Gabriel,

I have some code to allow only numerics, full point and hyphen in an edit box. So I can replace this line RETURN CallWindowProcA(GetPropA(hWnd,"edit_handler"),hWnd,uMsg,wParam,lParam) with just RETURN 0?

Sounds too easy!

'========================================
SUB NumEditSubclass(parent:WINDOW,id:INT) 'Allow nums, full stop and minus
'========================================
'Sub-class stuff
   hEdit=GETCONTROLHANDLE(parent,id)
   lpFn=SetWindowLongA(hEdit,-4,&NumEditHandler)
'Save the old handler as a property in the edit control, this way we don't need any global variables
   SetPropA(hEdit,"edit_handler",lpFn)
ENDSUB

'==================================================================
SUB NumEditHandler(hWnd:INT,uMsg:INT,wParam:INT,lParam:POINTER),INT 'Allow minus
'==================================================================
   SELECT uMsg
CASE @IDCHAR
IF ((wParam<0x30) OR (wParam>0x39)) AND (wParam<>ASC(".")) AND (wParam<>ASC("-")) AND (wParam<>0x08) THEN RETURN 1
ENDSELECT
RETURN CallWindowProcA(GetPropA(hWnd,"edit_handler"),hWnd,uMsg,wParam,lParam)
ENDSUB

Brian

fasecero

It should be, just remember we are talking specifically about WM_KEYDOWN

https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-keydown

QuoteReturn value
An application should return zero if it processes this message.