?
Solved

Menu item on Notepad

Posted on 1999-11-23
4
Medium Priority
?
216 Views
Last Modified: 2010-04-04
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?.
0
Comment
Question by:npatel
  • 2
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 200 total points
ID: 2230527
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
 

Author Comment

by:npatel
ID: 2231377
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
 
LVL 20

Expert Comment

by:Madshi
ID: 2231596
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
 

Author Comment

by:npatel
ID: 2232275
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

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question