#!/usr/bin/perl # test file for window's search # reference for API at http://dada.perl.it/#api and # http://webclub.kcom.ne.jp/ma/colinp/win32/fn2lib/f.txt use Win32::API; use Win32::GUI; # setup the window my $window = new Win32::GUI::Window( -name => "W_cogence", -title => "Cogence Project Search utility", -left => 0, -top => 0, -width => 500, -height => 300 ); $window->AddButton($window, -name => "B_Search", -title => "Search", -top => 100, -left => 0, -height=> 20); $window->Show(); my $windowHandle = Win32::GUI::GetActiveWindow(); my $exitcode = Win32::GUI::Dialog(); sub B_Search_Click { # extract the method from the dll my $api = new Win32::API('comdlg32.dll','FindText',[P],I); # determine number of byte needed for the char string based on whet +her # we are dealing with unicode or not. (pp 339 - Win32 Perl Programm +ing by Dave Roth) my $charSize = 1+Win32::API::IsUnicode(); # we want to build a structure like the following one #typedef struct { # DWORD lStructSize; -> will be long # HWND hwndOwner; -> handle of window (but what type is it ? we +'ll assume long) # HINSTANCE hInstance; -> long # DWORD Flags; -> long # LPTSTR lpstrFindWhat; -> see below / pointer to null terminat +ed string # LPTSTR lpstrReplaceWith;-> pointer to null terminated replace + string # WORD wFindWhatLen; -> size of find buffer # WORD wReplaceWithLen; ->size of replace buffer # LPARAM lCustData; -> will be long - see below for details # LPFRHOOKPROC lpfnHook; -> will be long (ignore) # LPCTSTR lpTemplateName; -> will be long #} FINDREPLACE, *LPFINDREPLACE; $struct = pack("L4(c*)2l5",((0) x 4), ($charSize*128) x 2, ((0) x 5 +)); FindText($struct); } # hInstance # If the FR_ENABLETEMPLATEHANDLE flag is set in the Flags member, # hInstance is a handle to a memory object containing a dialog box tem +plate. # If the FR_ENABLETEMPLATE flag is set, hInstance is a handle to a mod +ule # that contains a dialog box template named by the lpTemplateName memb +er. # If neither flag is set, this member is ignored. # lpstrFindWhat # Pointer to a buffer that a FINDMSGSTRING message uses to pass the nu +ll # terminated search string that the user typed in the Find What edit c +ontrol. # You must dynamically allocate the buffer or use a global or static a +rray so # it does not go out of scope before the dialog box closes. The buffer + should # be at least 80 characters long. If the buffer contains a string when + you # initialize the dialog box, the string is displayed in the Find What +edit control. # If a FINDMSGSTRING message specifies the FR_FINDNEXT flag, lpstrFind +What contains # the string to search for. The FR_DOWN, FR_WHOLEWORD, and FR_MATCHCAS +E flags indicate # the direction and type of search. If a FINDMSGSTRING message specifi +es the FR_REPLACE # or FR_REPLACE flags, lpstrFindWhat contains the string to be replace +d.
Heureux qui, comme Ulysse, a fait un beau voyage
Ou comme celui-là qui conquit la Toison,
Et puis est retourné plein d'usage et raison,
Vivre entre ses parents le reste de son âge!J. du Bellay, poëte angevin
In reply to Search tool by Foggy Bottoms
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |