Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Paul Breen on December 30, 2009, 09:12:35 PM

Title: Why is search different from TextBox to RichText?
Post by: Paul Breen on December 30, 2009, 09:12:35 PM
Hello:
I have a modest editor that uses the textbox, and the search function uses common dialogs with the code that someone posted, Christensen, I think. Search works fine with textbox but when I make a version using richtext the search words are never highlighted. Stepping through the code with debug print shows that the problem is that setsel does not show up in the dialog, even though the parameters, or arguments to the function are OK.
Do I need to do something special? I have seen messages that say you need a special message pump for richtext, but I don't understand why.
Secondly, I would like to customize the common file find control. I found c code that says you can modify the find dialog rc file on msdn but can I do this with powerbasic? Eventually, I want to add a number of features to the search dialog.
Should I try to avoid richtext and do what Jose did, use the scintilla control? It seems that there is a lot of examples just trying to understand how he did everything, but I would like to build my own from the 'ground up', well, just because
got to go library time out
Title: Re: Why is search different from TextBox to RichText?
Post by: José Roca on December 30, 2009, 10:07:22 PM
 
I don't have worked much with the Rich Edit control. For a text editor there are better options, such Scintilla.

Quote
Secondly, I would like to customize the common file find control. I found c code that says you can modify the find dialog rc file on msdn but can I do this with powerbasic?

Why not?

See: http://msdn.microsoft.com/en-us/library/ms646956%28VS.85%29.aspx

This is the template:


/*++

Copyright (c) Microsoft Corporation. All rights reserved.

Module Name:

    findtext.dlg

Abstract:

    This module contains the resource descriptions for the Win32
    find and replace common dialogs.

Revision History:

--*/



//
//  Find and Replace Dialogs.
//

FINDDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 30, 73, 236, 62
STYLE WS_BORDER | WS_CAPTION | DS_MODALFRAME | WS_POPUP | WS_SYSMENU |
      DS_3DLOOK
CAPTION "Find"
FONT 8, "MS Shell Dlg"
BEGIN
    LTEXT           "Fi&nd what:", -1, 4, 8, 42, 8
    EDITTEXT        edt1, 47, 7, 128, 12, WS_GROUP | WS_TABSTOP | ES_AUTOHSCROLL

    AUTOCHECKBOX    "Match &whole word only", chx1, 4, 26, 100, 12, WS_GROUP
    AUTOCHECKBOX    "Match &case", chx2, 4, 42, 64, 12

    GROUPBOX        "Direction", grp1, 107, 26, 68, 28, WS_GROUP
    AUTORADIOBUTTON "&Up", rad1, 111, 38, 25, 12, WS_GROUP
    AUTORADIOBUTTON "&Down", rad2, 138, 38, 35, 12

    DEFPUSHBUTTON   "&Find Next", IDOK, 182, 5, 50, 14, WS_GROUP
    PUSHBUTTON      "Cancel", IDCANCEL, 182, 23, 50, 14
    PUSHBUTTON      "&Help", pshHelp, 182, 45, 50, 14
END


REPLACEDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 44, 230, 94
STYLE WS_BORDER | WS_CAPTION | DS_MODALFRAME | WS_POPUP | WS_SYSMENU |
      DS_3DLOOK
CAPTION "Replace"
FONT 8, "MS Shell Dlg"
BEGIN
    LTEXT           "Fi&nd what:", -1, 4, 9, 48, 8
    EDITTEXT        edt1, 54, 7, 114, 12, WS_GROUP | WS_TABSTOP | ES_AUTOHSCROLL

    LTEXT           "Re&place with:", -1, 4, 26, 48, 8
    EDITTEXT        edt2, 54, 24, 114, 12, WS_GROUP | WS_TABSTOP | ES_AUTOHSCROLL

    AUTOCHECKBOX    "Match &whole word only", chx1, 5, 46, 104, 12, WS_GROUP
    AUTOCHECKBOX    "Match &case", chx2, 5, 62, 59, 12

    DEFPUSHBUTTON   "&Find Next", IDOK, 174, 4, 50, 14, WS_GROUP
    PUSHBUTTON      "&Replace", psh1, 174, 21, 50, 14
    PUSHBUTTON      "Replace &All", psh2, 174, 38, 50, 14
    PUSHBUTTON      "Cancel", IDCANCEL, 174, 55, 50, 14
    PUSHBUTTON      "&Help", pshHelp, 174, 75, 50, 14
END


Modify it, include it in your resource file, compile the rc file, include the resulting pbr file in your application and fill the FINDREPLACE structure with a pointer to that template.
Title: Re: Why is search different from TextBox to RichText?
Post by: Paul Breen on December 30, 2009, 10:28:54 PM
Hey, thanks, but . . .
I' ll try to figure this out later, but only 15 min left of intenet. . .
how do I set a pointer to the pbr resource?
It has to be one of the find sturcture fields, right?
the wifi is out, and the mean libraians log you off here after 50 min.
Happy new year :D

postscript:

Anybody out there doing scintilla with pb?

should I post questions to the SED forum or here?
Title: Re: Why is search different from TextBox to RichText?
Post by: José Roca on December 31, 2009, 12:11:26 AM
Quote
It has to be one of the find sturcture fields, right?

According to the M$ documentation you have to add FR_ENABLETEMPLATEHANDLE to the Flags member of the FINDREPLACE structure, and hInstance to the handle to a module that contains a dialog box template named by the lpTemplateName member.

Quote
how do I set a pointer to the pbr resource?

Using the MAKEINTRESOURCE macro or function:


FUNCTION MAKEINTRESOURCE (BYVAL wInteger AS WORD) AS DWORD
   FUNCTION = MAK(DWORD, wInteger, 0)
END FUNCTION


As it uses a WORD value, add an identifier before the dialog name, e.g.


#define FINDDLGORD 10

Title: Re: Why is search different from TextBox to RichText?
Post by: Steve Hutchesson on December 31, 2009, 06:56:04 AM
Paul,

I can give you the code to do this if you are interested, two RC dialogs and the dialog functions as basic code. This is a bit overkill as its for a rich text editor but it will certainly find and replace words if thats what you are after.
Title: Re: Why is search different from TextBox to RichText?
Post by: Paul Breen on January 04, 2010, 07:43:39 PM
Quote from: Steve Hutchesson on December 31, 2009, 06:56:04 AM
Paul,

I can give you the code to do this if you are interested, two RC dialogs and the dialog functions as basic code. This is a bit overkill as its for a rich text editor but it will certainly find and replace words if thats what you are after.

Yeah, thanks, I would apprecite it. Just got back online, school has started. In the meantime I wrote a dialog that searces forward, but you could say it is not feature-rich. I am using richtext so I can show results to the user in color, underlined, or whatever. Would you post a download on this topic?
Paul Breen