Jump to content

Recommended Posts

Posted (edited)

It's usually called "Strike(through)", not "Stripe", and maybe put an Underline under the characters in the bmp's that can be ctrl'ed, and maybe put a lowercase "u" in front of "uLine".

It looks nice, havent tried it though, cant be bothered installing fonts nor compile it as exe. :)

Btw, please put all the files in a folder before zipping, so people dont have to create a folder in their examples scripts folder themselfes.

Edited by Werty

Some guy's script + some other guy's script = my script!

Posted
7 hours ago, Werty said:

It's usually called "Strike(through)", not "Stripe", and maybe put an Underline under the characters in the bmp's that can be ctrl'ed, and maybe put a lowercase "u" in front of "uLine".

It looks nice, havent tried it though, cant be bothered installing fonts nor compile it as exe. :)

Btw, please put all the files in a folder before zipping, so people dont have to create a folder in their examples scripts folder themselfes.

Good advice!
Made some adjustments :)

btw, you can run the script as is (no compiling needed for that) if you wanna test it out, it just opens the helpfile with no arguments as you can see in the picture.

Posted (edited)

UPDATE:

  1. code cleanup
  2. added minimalistic sci-fi sounds
  3. better text on buttons and they have labels now
  4. better shortcuts
  5. open and save buttons now work as intended
  6. helpfile got an update
  7. code can be tested when not compiled
  8. removed a bug

Enjoy and let me know what you think :)

PS:

If anyone knows how to make the edit scroll up / down when I use the mouse to scroll, let me know.
I looked at this topic, but have no clue what to make of the code:

 

 

 

Edited by TheAutomator
Posted
17 hours ago, TheAutomator said:

If anyone knows how to make the edit scroll up / down when I use the mouse to scroll, let me know.

Does this work for you ?

_GUICtrlRichEdit_SetEventMask($edit, BitOR($ENM_SCROLL, $ENM_SCROLLEVENTS))
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

...

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd($tNMHDR.hWndFrom)
    $iCode = $tNMHDR.Code
    Switch $hWndFrom
        Case $edit
            Select
                Case $iCode = $EN_MSGFILTER
                    Local $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    Switch $tMsgFilter.msg
                        Case $WM_VSCROLL
                            _GUICtrlRichEdit_ScrollLines($edit, ($tMsgFilter.wparam = 1 ? 1 : -1))
                    EndSwitch
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

"I think you are searching a bug where there is no bug..."

Posted (edited)

Pixelsearch,

6 hours ago, pixelsearch said:

Does this work for you ?

_GUICtrlRichEdit_SetEventMask($edit, BitOR($ENM_SCROLL, $ENM_SCROLLEVENTS))
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

...

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $tNMHDR, $hWndFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd($tNMHDR.hWndFrom)
    $iCode = $tNMHDR.Code
    Switch $hWndFrom
        Case $edit
            Select
                Case $iCode = $EN_MSGFILTER
                    Local $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    Switch $tMsgFilter.msg
                        Case $WM_VSCROLL
                            _GUICtrlRichEdit_ScrollLines($edit, ($tMsgFilter.wparam = 1 ? 1 : -1))
                    EndSwitch
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

Nice! You made my day! :D

The code you provided worked like a charm, but did raise some questions (if you don't mind replying to them).

1: why the #forcref, is it needed in this code?
2: why using 'switch' and 'select' if we can simply use 'if'?

The version i'm gonna put in the project:

_guictrlrichedit_seteventmask($edit, bitor($enm_scroll, $enm_scrollevents))

guiregistermsg($wm_notify, "wm_notify")

func wm_notify($hwnd, $imsg, $wparam, $lparam) ; make scrolling in the edit possible (thanks pixelsearch!)
    local $tnmhdr, $hwndfrom, $icode
    $tnmhdr = dllstructcreate($tagnmhdr, $lparam)
    $hwndfrom = hwnd($tnmhdr.hwndfrom)
    $icode = $tnmhdr.code
    if $hwndfrom = $edit then
        if $icode = $en_msgfilter then
            local $tmsgfilter = dllstructcreate($tagmsgfilter, $lparam)
            if $tmsgfilter.msg = $wm_vscroll then _guictrlrichedit_scrolllines($edit, ($tmsgfilter.wparam = 1 ? 1 : -1))
        endif
    endif
    return $gui_rundefmsg
endfunc

Thanks for the help!
Figuring out how to correctly do more advanced specific stuff, like finding the right parameters, using dllstructs and worrying about not using code correctly can be dificult at times :sweating:

MiniMark (now version 2) is uploaded.
 

Edited by TheAutomator
Posted

@TheAutomator glad it helped you.

By the way, as you don't want to add scrollbars (in your richedit control styles) then you can simplify the mask, keeping only $ENM_SCROLLEVENTS to take care of notifications for mouse wheel events :

; _GUICtrlRichEdit_SetEventMask($edit, BitOR($ENM_SCROLL, $ENM_SCROLLEVENTS))
_GUICtrlRichEdit_SetEventMask($edit, $ENM_SCROLLEVENTS)

 

Just now, TheAutomator said:

1: why the #forcref, is it needed in this code?

You'll find the answer in this thread and also in that one

Just now, TheAutomator said:

2: why using 'switch' and 'select' if we can simply use 'if'?

No problem. If you prefer to code with 'if' it will give the same result :)

"I think you are searching a bug where there is no bug..."

Posted

In fact if you set the mask to only scroll events :

_GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_SCROLLEVENTS)

then the WM_NOTIFY message proc can be as simple as :

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
  Local $tFilter = DllStructCreate($tagMSGFILTER, $lParam)
  If $tFilter.hwndFrom = $hRichEdit Then _GUICtrlRichEdit_ScrollLines($tFilter.hwndFrom, $tFilter.wParam ? 1 : -1)
  Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

Posted
9 hours ago, Nine said:

In fact if you set the mask to only scroll events :

_GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_SCROLLEVENTS)

then the WM_NOTIFY message proc can be as simple as :

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
  Local $tFilter = DllStructCreate($tagMSGFILTER, $lParam)
  If $tFilter.hwndFrom = $hRichEdit Then _GUICtrlRichEdit_ScrollLines($tFilter.hwndFrom, $tFilter.wParam ? 1 : -1)
  Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

Perfect! Love it! :D Thank you so much!
Gonna put it like that inside of the code now :)

Posted
28 minutes ago, TheAutomator said:

Next task:

Spoiler
const $source_path = @ScriptDir & '\minimark'
Const $image_background = $source_path & '\gui.bmp'
Const $image_blue = $source_path & '\blue.bmp'
Const $image_bold = $source_path & '\bold.bmp'
Const $image_default = $source_path & '\default.bmp'
Const $image_exit = $source_path & '\exit.bmp'
Const $image_green = $source_path & '\green.bmp'
Const $image_italic = $source_path & '\italic.bmp'
Const $image_open = $source_path & '\open.bmp'
Const $image_red = $source_path & '\red.bmp'
Const $image_save = $source_path & '\save.bmp'
Const $image_struck = $source_path & '\struck.bmp'
Const $image_under = $source_path & '\under.bmp'
Const $image_white = $source_path & '\white.bmp'

Const $sound_start = $source_path & '\start.wav'
Const $sound_click = $source_path & '\click.wav'
Const $sound_alert = $source_path & '\alert.wav'
Const $sound_stop = $source_path & '\stop.wav'

Const $color_gui_transparant = 0xff00ff
Const $color_title = 0x999999
Const $color_edit_background = 0x00323232
Const $color_edit_gray = 0x00b4b4b4
Const $color_edit_red = 0x006600ff
Const $color_edit_green = 0x0000ff66
Const $color_edit_blue = 0x00ff6600
Const $color_edit_white = 0x00ffffff

Const $file_manual = $source_path & '\minimark.mnm'

..fix the new paths in MiniMark.au3 :lol:

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

argumentum,

Can you tell me why making an extra variable would be better? Does @scriptdir slow the script down when used a lot? :think:

1 hour ago, argumentum said:

Request: Portable version, script version, and user level install too ( for office workers ).

PS: there is code in the help file ( I if memory serves, else, the forum ) to load the font without installing it first, from file or resource.

About the request for the fonts, you mean this right?
https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_AddFontResourceEx.htm

I'm not sure if temporary installing the font every time the script get's opened is a good idea, as shown in the link it installs the font only for the current session but still installs it... I need to reseach it a little more to be sure tho.

Script version is already possible if you mean running it uncompiled?

And user level install means commenting out this line from the installer I suppose:

#RequireAdmin

Compiling MiniMark to an exe and leaving the sounds, images and help file with it technically makes it portable.
Using fileinstall is also an option, do you have a preference?
If you mean working with embedded resources, well thats new for me, I might make mistakes but i'll give it a try.

Edited by TheAutomator
Posted (edited)
4 hours ago, TheAutomator said:

Compiling MiniMark to an exe and leaving the sounds, images and help file with it technically makes it portable.

#autoit3wrapper_icon=setup\setup.ico, 201
... ...
DllCall('shell32.dll', 'long', 'SetCurrentProcessExplicitAppUserModelID', 'wstr', StringStripWS(@ScriptName, 8)) ; look at _WinAPI_SetCurrentProcessExplicitAppUserModelID()
$form = GUICreate('MiniMark Setup', 300, 300, Default, Default, $ws_popup, $ws_ex_layered)
Gui_SetIconIf("setup\icon.ico", 201)
Func Gui_SetIconIf($sIconFile, $iIconID)
    If @AutoItExe = @ScriptFullPath And Not FileGetSize($sIconFile) Then
        GUISetIcon(@AutoItExe, $iIconID)
    Else
        GUISetIcon($sIconFile)
    EndIf
EndFunc   ;==>Gui_SetIconIf

That function I use in one of my scripts where if compiled uses the internal Icon, else, use the file but if is there, maybe the user wanted a different one so use the one on disk.

 Similarly you can keep all the files on disk or embed it in the executable, or both as described above. 

4 hours ago, TheAutomator said:

And user level install means commenting out this line from the installer I suppose:

It would take installing to where a user can modify anything that a non-admin could. @AppDataDir could be a good folder as @ProgramFilesDir requires admin level.
In cv.exe there is code to elevate and de-elevate. You can use that or scrape the forum for the original sources. That would give the user the option to install as admin or user.

4 hours ago, TheAutomator said:

Can you tell me why making an extra variable would be better? Does @scriptdir slow the script down when used a lot? :think:

Oh, that. I wanted to edit as little as possible and, have what I wanted, hence the extra variable. As is from the download, it didn't run.

4 hours ago, TheAutomator said:

Script version is already possible if you mean running it uncompiled?

Yes it is. The reason for my requests is to have a nice product that would please as many users as possible, in as many circumstances as there may be.
Maybe 10 users will use your script as a product, or a million, no clue. But if your script is an example of how to code something, better :)

These requests are perfectly doable. Is just a matter of coding it that way, if is not too far from what you had in mind.

5 hours ago, TheAutomator said:

Next task: adding a find/replace window.

Along those lines of expanding capabilities, making the GUI resizable would be nice.

Resize the font too ( for those that need bigger letters because they don't see very well ).
"Zoom in / out: ctrl + scroll" with memory, for the next time is loaded.

One feature at the time is good.

Thanks for paying attention to my demands requests :) 

Edited by argumentum
English

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

argumentum,

I added it to the example scripts to share it with users who like this kind of software, and to show others how to use the rich edit control and create custom GUIs. 🙂

The goal is to have a minimalistic RTF editor with files that have custom icons and open directly with MiniMark. Personally, I use it as a quick notes app for all kinds of lists (to-dos, series to binge, things to buy...) that I can just double-click and edit when needed. I'm not planning to tweak the icons, style, or add a huge amount of options becouse that would make it "maximalistic" :mellow:.

That being said, allowing users to choose the installation location is a great idea and will be added soon! Keep in mind that the software is designed to be compiled and installed (custom icons, fonts, and right-click menu entries). Making it portable would mean users have to manually open or drag icon-less files into the executable, which isn’t very convenient..

For testing the script as is please check the README: drag MiniMark.au3 into the MiniMark folder so it can access its files properly, then it should work.

I'm doing my best to make it work as smooth as possible in my free time, but this is an open-source project in a forum full of developers who can tweak it to their liking. That doesn’t mean I’m ignoring requests, I gladly accept help with code and small handy improvements for those who want to contribute!

It’s all about finding the right balance between keeping it light but good. An update is coming soon, so let’s see what I can do. 😃

Edited by TheAutomator
a few typos removed
Posted (edited)

MiniMark 3 is here!

Now we have:

  • a custom (still buggy) scrollbar
  • a search window to find and replace text (ctrl+f -> should also make a button for it that)
  • installer is a little smaller

Upcoming:

  • user level install option (as deman... I mean, requested by argumentum) ;)
  • a settings window, and writing an INI file to remember some settings (like enabeling sounds or the last zoom amount)

Making the gui resizable is not as easy as it seems, I tried to do that in the past with a custom gui and got very frustrated when using a borderles window that could get maximized by hitting the top of the screen but not register as maximized for example... We'll see :)

Readers of this post, I kindly request your help!

Please have a look at the custom scrollbar, and let me know if there is a way to scroll the rich edit to a specific line without moving the caret or changing the selection of the edit control, that's what i'm trying to do but the code is a little dirty. :huh2:

#Region scrollbar

    $scroll_drag = False ; are we dragging the scroll button?

    Func check_scroll_clicked() ; always sets $scroll_cursor variable
        Local $scroll_cursor = GUIGetCursorInfo($form)
        If _
            $scroll_cursor[0] >= 300 And _
            $scroll_cursor[0] <= 310 And _
            $scroll_cursor[1] >= 60 And _
            $scroll_cursor[1] <= 369 _
        Then $scroll_drag = True
    EndFunc

    Func scroll() ; label : 300, 60, 10, 20 bar: 300, 60, 10, 310 lies visible: around 28
        Local $scroll_x = 300 ; x of $scroll control at all times
        Local $scroll_min_y = 60, $scroll_max_y = 350 ; range of y movement for $scroll (top of frame till bottom - height)

        $scroll_cursor = GUIGetCursorInfo($form)[1] ; get y position of cursor
        if $scroll_cursor < $scroll_min_y then $scroll_cursor = $scroll_min_y
        if $scroll_cursor > $scroll_max_y then $scroll_cursor = $scroll_max_y
        GUICtrlSetPos($scroll, $scroll_x, $scroll_cursor) ; drag scroll button within range of background bar

        $scroll_ratio = ($scroll_cursor - $scroll_min_y) / ($scroll_max_y - $scroll_min_y) ; calculate scroll position percentage between 0 and 1
        $scroll_last = _GUICtrlRichEdit_GetLineCount($Edit)

        If $scroll_last > 27 then $scroll_last -= 25 ; scroll to end but not over end
        $scroll_first = _GUICtrlRichEdit_GetNumberOfFirstVisibleLine($edit)

        $scroll_calculate = Int($scroll_ratio * $scroll_last) - $scroll_first ; calculate where to walk to

        consolewrite(_GUICtrlRichEdit_GetLineCount($Edit) & '---' & $scroll_calculate & '---' & $scroll_ratio & @CRLF)
        _GUICtrlRichEdit_ScrollLines($edit, $scroll_calculate)
    EndFunc

#endregion

while 1
    switch guigetmsg()
        case $gui_event_close, $button_exit
            quit()

        case $GUI_EVENT_PRIMARYDOWN
            check_scroll_clicked()

        Case $GUI_EVENT_MOUSEMOVE
            If $scroll_drag Then scroll()

        Case $GUI_EVENT_PRIMARYUP
            $scroll_drag = False
            
            ...

Thanks to everyone that contributed, liked and suported this project!
See you soon with updates and replys :D

Edited by TheAutomator

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...