Jump to content
  • Advertisement
Sign in to follow this  
kingpinzs

Help with windows api programming

This topic is 5456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

can any one show were a tutorial or example programe is that uses the find dialog box and how to make one for my windows program and also how to do word wrap? Thanks Jeremy

Share this post


Link to post
Share on other sites
Advertisement
Yes, MSDN has an example of using the Find/Replace common dialog. I assume it also has information about word wrapping.

Share this post


Link to post
Share on other sites
I tryed that but could not find an example for it do you have a link to it? this is what I have


Finding Text
This topic describes sample code that displays and manages a Find dialog box so the user can specify the parameters of a search operation. The dialog box sends messages to your window procedure so you can perform the search operation.

The code for displaying and managing a Replace dialog box is similar, except that it uses the ReplaceText function to display the dialog box. The Replace dialog box also sends messages in response to user clicks on the Replace and Replace All buttons.

To use the Find or Replace dialog box, you must perform three separate tasks:

Get a message identifier for the FINDMSGSTRING registered message.
Display the dialog box.
Process FINDMSGSTRING messages when the dialog box is open.
When you initialize your application, call the RegisterWindowMessage function to get a message identifier for the FINDMSGSTRING registered message.

UINT uFindReplaceMsg; // message identifier for FINDMSGSTRING

uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
To display a Find dialog box, first initialize a FINDREPLACE structure and then call the FindText function. Note that the FINDREPLACE structure and the buffer for the search string should be a global or static variable so it does not go out of scope before the dialog box closes. You must set the hwndOwner member to specify the window that receives the registered messages. After you create the dialog box, you can move or manipulate it by using the returned handle.

Hide Example

FINDREPLACE fr; // common dialog box structure
HWND hwnd; // owner window
CHAR szFindWhat[80]; // buffer receiving string
HWND hdlg = NULL; // handle to Find dialog box

// Initialize FINDREPLACE
ZeroMemory(&fr, sizeof(fr));
fr.lStructSize = sizeof(fr);
fr.hwndOwner = hwnd;
fr.lpstrFindWhat = szFindWhat;
fr.wFindWhatLen = 80;
fr.Flags = 0;

hdlg = FindText(&fr);

Share this post


Link to post
Share on other sites
can some one show me how to use msdn code in a sample windows programe?

Finding Text
This topic describes sample code that displays and manages a Find dialog box so the user can specify the parameters of a search operation. The dialog box sends messages to your window procedure so you can perform the search operation.

The code for displaying and managing a Replace dialog box is similar, except that it uses the ReplaceText function to display the dialog box. The Replace dialog box also sends messages in response to user clicks on the Replace and Replace All buttons.

To use the Find or Replace dialog box, you must perform three separate tasks:

Get a message identifier for the FINDMSGSTRING registered message.
Display the dialog box.
Process FINDMSGSTRING messages when the dialog box is open.
When you initialize your application, call the RegisterWindowMessage function to get a message identifier for the FINDMSGSTRING registered message.

UINT uFindReplaceMsg; // message identifier for FINDMSGSTRING

uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
To display a Find dialog box, first initialize a FINDREPLACE structure and then call the FindText function. Note that the FINDREPLACE structure and the buffer for the search string should be a global or static variable so it does not go out of scope before the dialog box closes. You must set the hwndOwner member to specify the window that receives the registered messages. After you create the dialog box, you can move or manipulate it by using the returned handle.

Hide Example

FINDREPLACE fr; // common dialog box structure
HWND hwnd; // owner window
CHAR szFindWhat[80]; // buffer receiving string
HWND hdlg = NULL; // handle to Find dialog box

// Initialize FINDREPLACE
ZeroMemory(&fr, sizeof(fr));
fr.lStructSize = sizeof(fr);
fr.hwndOwner = hwnd;
fr.lpstrFindWhat = szFindWhat;
fr.wFindWhatLen = 80;
fr.Flags = 0;

hdlg = FindText(&fr);

When the dialog box is open, your main message loop must include a call to the IsDialogMessage function. Pass a handle to the dialog box as a parameter in the IsDialogMessage call. This ensures that the dialog box correctly processes keyboard messages.

To monitor messages sent from the dialog box, your window procedure must check for the FINDMSGSTRING registered message and process the values passed in the FINDREPLACE structure as in the following example:

Hide Example

LPFINDREPLACE lpfr;

if (message == uFindReplaceMsg){

// Get pointer to FINDREPLACE structure from lParam.

lpfr = (LPFINDREPLACE)lParam;

// If the FR_DIALOGTERM flag is set,
// invalidate the handle identifying the dialog box.

if (lpfr->Flags & FR_DIALOGTERM){
hdlg = NULL;
return 0;
}

// If the FR_FINDNEXT flag is set,
// call the application-defined search routine
// to search for the requested string.

if (lpfr->Flags & FR_FINDNEXT)
SearchFile(lpfr->lpstrFindWhat,
(BOOL) (lpfr->Flags & FR_DOWN),
(BOOL) (lpfr->Flags & FR_MATCHCASE));

return 0;

}



Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!