Menu item on Notepad

Is there a way I can add a menu item or button to Notepad.

I have seen some sources that do add a button to the title bars in a delphi app but none for other apps like notepad. These sources require hooks to windows messages for the application.

How does one hook into Notepads messages so that I can use on button click events?.
npatelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MadshiCommented:
There is a way. You'll have to write a little dll. Then hook notepad's main window (SetWindowsHookEx). Now hook all messages. When you receive a WM_NCPAINT, you should draw your additional button to the title bar (e.g. with BitBlt). There are of course more messages that you have to hook and handle, for the button look at all the WM_NC* messages (NC = non client).

That's no easy stuff...

Regards, Madshi.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
npatelAuthor Commented:
Thank you for your suggestion.

It will help me to get started in the right direction.

If you have a sample code of using SetWindowsHookEX via a dll, it would help me a lot. The sample need not deal with my question just looking for a source to get started with.



0
MadshiCommented:
Sample code for a C grade?? Hmmm...

Okay, I've my friendly day today...

The following app/dll combination disables the keyboard system wide.

// app

var dll, keybHook : cardinal;

procedure DisableKeyboard;
begin
  dll:=LoadLibrary('c:\yourAppPath\hook.dll');
  keybHook:=SetWindowsHookEx(WH_KEYBOARD,GetProcAddress(dll,'hookProc'),dll,0);
end;

procedure EnableKeyboard;
begin
  UnhookWindowsHookEx(keybHook);
  FreeLibrary(dll);
end;

// dll

library hook;

function hookProc(code, wParam, lParam: integer) : integer; stdcall;
begin
  result:=1;
end;

exports hookProc index 1 name 'hookProc';

end.

Regards, Madshi.
0
npatelAuthor Commented:
Thanks Madshi:0)

May be I was harsh on the C grade
you deserve better ,an 'A+' for the example.

All the best
NPatel.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.