

JohnLM
Members-
Content Count
358 -
Joined
-
Last visited
Community Reputation
27 ExcellentTechnical Information
-
Delphi-Version
Delphi 11 Alexandria
Recent Profile Visitors
23909 profile views
-
A slight change of plans. The original goal was to create a list of values that I could use to parse strings based off a main or master string--for databases and other uses. So, something like a header with fields would have worked for the visual aid. But headers don't always give the true char-length. It is the actual line of text that matters most in these situations. However, during the process of development, I decided I wanted to have something visual. And I managed to get a working version late last night after my initial post here on this forum. But I did not post it up here. I decided that a short video demo would suffice. It took some time for me to figure out and I will post that later on. Until then. Today, working on it some more, I realize now, that I can turn this into a utility app to parse the strings that I want and build the database in this same process.
- 7 replies
-
- delphi xe7
- trackbar
-
(and 1 more)
Tagged with:
-
I just made some edits to the topic. I did not complete this post. I pressed the [submit] button too quicky. Anyway. In the 2nd method, I have the trackbar and spinedit controls. And below that, I have an editbox also, and below that, two memo's, one for the the strings and another for the value pairs to use in parsing out the strings. And then, I have [Add] and [Del] buttons. I am designing the app to show in real-time, the text I am selecting via the trackbar and spinedit so that I can see the values I need. The real-time feedback will help to show me what I am selecting. If I can get a working demo, I will post it up here. It might be useful in some way or idea for others.
- 7 replies
-
- delphi xe7
- trackbar
-
(and 1 more)
Tagged with:
-
I was wondering if there is a trackbar with two sliders, so that I can use as a min/max setting--i.e., for making text selection ranges. I am not qualified to extend upon the built-in version that comes with Delphi, let alone build one from scratch as a new component. 1st method: I have often come into idea situations with I wish Delphi has one. Today, I had an idea about creating a string utility app to parse strings with (integer) parameters and thought that entering numbers would be a tad bit tedious and then I came up with a trackbar idea, where I build a list of start/end or min/max range and have the app give me the actual position and length position(s) for their values for the string "ABC 123 DEF 456 7GH8 IJKL9". And, given the TrackBarEx below: with the following parameters: TrackBarEx(min=5, max=3) and using those two values, calculate the string to be "123". The trackbarex would return two values, the starting and ending position for the string, per user control. The above is a crude way of explaining what I am trying to do. It may not be as clear or accurate. I would have to calculate the position and distance in the string to get the values of the string position(s) and put those values in a list for me to parse out the string bits. Thus, the following layout of the string, using the trackbarex, I would parse out each of the six text string positions in a list: 1 2 3 123456789012345678901234567890 ABC 123 DEF 456 7GH8 IJKL9 and the returned values would be: 1, 3 ABC 5, 7 123 9,11 DEF 13,15 456 17,20 7GH8 22,26 IJKL9 NOTE: in the above example, the strings "ABC" through "IJKL9" would not be returned. I am just showing that for visual/aesthetics purposes. The trackbarex would contain two sliders and have a minval and maxval that are returned. Not that they are returned but that they are the values of each of the sliders as the user moves them. I would just take those two values and use those to calculate the position within the string. 2nd/alternate method: For now, I have an other method that I am working on right now in hopes to produce the same idea by using one standard TrackBar and a SpinEdit and I would manually set the length of the string to capture every time I move the trackbar to a position. Thus, move trackbar to position 1, set the spinedit to 3, calculate the string and parse it to "ABC". Rinse and repeat for "123", thus move trackbar to position 5, set the spinedit to 3, calculate the string and parse it to "123".., rinse and repeat, . . . and so on.
- 7 replies
-
- delphi xe7
- trackbar
-
(and 1 more)
Tagged with:
-
Delphi project source codes is all on one line
JohnLM replied to JohnLM's topic in Delphi IDE and APIs
Ah, yes.. AdjustLineBreaks() thank you for that. I did not know about that function. I will save the code snippets you provided for future projects. Although I have not tested it, I believe that the later versions of Delphi provide the feature build-in under: \Options\Editor\Line Endings\Inconsistent line endings: [Convert all files to CRLF] The above is in D12.2 on my win10 tablet. So, I would not have to go through the steps you outlined in your previous repy, Remy. The select/copy/paste into win10's notepad would probably work without issues, though I have not tested it. I will update true/false once I get around to testing this. Thanks again for your help, Remy.- 4 replies
-
- delphi xe7
- all-on-one-line
-
(and 1 more)
Tagged with:
-
Delphi project source codes is all on one line
JohnLM replied to JohnLM's topic in Delphi IDE and APIs
When a new project is created, the default pattern is #13#10 (or, #$D#$A) and has been this way for ages. Unless there is a way to by-pass this by setting delphi's environment code to handle #10, I don't know how it could be done. However, I have one theory and that was already explained in my previous post. The developer of CEF4Delphi had probably been using notepad++ or some other editor that uses on #10, and at some point was pushing all the source code into delphi projects, that is, was saving them this way, as #10. And, since Delphi can handle the #10, it went on this way up to this point for the CEF4Delphi project. ill regardless of which editor was used, and the method to transport the source codes, the saved state was using #10 and that is what was pushed into these CEF4Delphi demos. So all the demo's pas files have #10 in them, and Delphi opens them without any issues. If a person goes into the Delphi IDE and select/copy's it to the clipboard to paste into Windows standard notepad, or proceeds to open any of the demos in notepad, notepad will open it as one line because of the missing #13 char for every linefeed before wrapping to the next line, as shown below. For now, I will have to deal with this in my own way. And I have figure out one way to deal with this issue in order to continue using the demo projects as I add or write my own custom functions in them and/or push them into my notepad file of codes snippets. function fix13and10str(sStr: string): string; var s: string; begin s := StringReplace(sStr, #$A, #$D#$A, [rfReplaceAll]); result:= StringReplace(s, #$D#$D#$A, #$D#$A, [rfReplaceAll]); end; // example usage procedure TForm1.btnProcessClick(Sender: TObject); var s: string; begin s := Fix13And10Str(clipboard.AsText); m1.Lines.Add(s); end; I will figure out a way to fix this the code (above) to handle a source file copied to the clipboard to process when copying whole source codes from the Delphi IDE that could potentially be hundreds of lines. For now, I am on the right track. For the record, I do not use notepad++ and I am not saying it is bad or anything. I just never found uses for it up to this point.- 4 replies
-
- delphi xe7
- all-on-one-line
-
(and 1 more)
Tagged with:
-
Specs: Delphi XE7, VCL, Windows 7 So, while working in a new (isolated) project to figure out a better function() to use in one of my projects (SimpleBrowser), I stumbled upon a problem. And the subject says it all. I need to pull a custom function that I wrote from the SimpleBrowser project and work on it as a separate project. So, I select and copy it to the clipboard and then paste it into a new delphi project. The code snippet is pasted correctly in the IDE. However, when I selected and copied that code again from that new project and pasted it into notepad (because for every new function I create, I added to my "delphi code snippet" file) all the source code are on one line. If I follow that same process but copy from the original project, I get the same issues, all the source codes are on one line--there is no carriage returns, no formating, etc.. I tried to figure out why this is happening, and I can only assume that something unique was set in the IDE of this demo project, "SimpleBrowser" but I can't figure it out. This SimpleBrowser is a demo from the "CEF4Delphi" project. The folder is: "..\CEF4Delphi\WebView4Delphi\demos\Delphi_VCL\SimpleBrowser" Does anyone have any clues as to what is going on ?
- 4 replies
-
- delphi xe7
- all-on-one-line
-
(and 1 more)
Tagged with:
-
progress update. . . some videos via embed fail's to play. Unfortunately, I am unable to play certain embeded videos. I am finding a lot now and it is causing me a lot of grief. Does anyone know what is causing this and/or is this a known problem or maybe the channel is responsible? I don't know. I am just grasping at straws now. I really want this project to work.
- 12 replies
-
- delphi xe7
- youtube
-
(and 1 more)
Tagged with:
-
update on this endeavor. . . Hi All. Thanks for your ideas/suggestions. Sorry for the long delay. I had gone down a rabbit hole while trying to solve an initial idea to create a unique list of YT HASHes that turned a bit sour on me. What I wanted to do was, after receiving a YT URL link, I would parse out the HASH part (so I can store it in a list) and then later, rebuild it into a proper YT URL, thus, https://www.youtube.com/watch?v=+HASH at will, say for instance when I click on the [Go] button. The issue I wanted to catch was duplicate URL's, because I may have selected the same link elsewhere in the YT dashboard page. I will have to figure it out another time. Anyway. I may have a better idea for the combobox list--its funtional purpose and storage. I can auto-update the list, populating it by copying all the links that I am interested in while on the Youtube main dashboard page. Sort of like creating a personal tvguide list for today, for instance. And then when I'm ready, I start watching the videos. Thus.. A) Each time I right-click-select-to-clibpboard on a video link, my app will sinse the Windows message and detect that I have a CF_TEXT format and take that text (from the clipboard) and parse out the HASH and add that to the combobox list, and B) When I finish watching something, I can update the list to show that I watched the video by padding a "Y" in the list. And later, I can save that list into a master list somewhere, or a database. I have not decided yet. I am working on these ideas as I write this response. But I have working code snippets for both A and B that I worked out earlier. They work. I can receive notification that the clipboard has something (text) in it and snip the contents (the YT URL) and parse it. I just need to rework those code snippet(s) into this youtube player project. And of course, I welcome your thoughts. I will update on this projects progress soon.
- 12 replies
-
- delphi xe7
- youtube
-
(and 1 more)
Tagged with:
-
Actually, the screenshot in my previous post does show it :) But here is how I call the URL. What I do is grab a URL via rightclick+copy from youtube's main dashboard and parse it to change its format and feed that into the Navigate() command in the button's [Go] event: /// 1 function findStr(fStr, sStr: string): boolean; begin if pos(fStr,sStr,1)>0 then result:=true else result:=false; end; /// 1 - end /// 2 function findStrReplace(sStr: string; fStr: string; rpStr: string): string; begin if pos(fStr,sStr,1)>0 then result := StringReplace(sStr,fStr,rpStr,[rfReplaceAll, rfIgnoreCase]); end; /// 2 - end procedure TMainForm.GoBtnClick(Sender: TObject); var s: string; begin { change this https://www.youtube.com/watch?v=ZJhJILyS388 to this https://www.youtube.com/embed/ZJhJILyS388 } s:=addresscb.Text; addressCb.Text:=findStrReplace(s, 'watch?v=', 'embed/'); //# 2 WVBrowser1.Navigate(AddressCb.Text); end; I'm sure there are better ways to code it than how I did it but you get the idea. Also, I have to do something similar for the Dailymotion URL's, which a bit more complicated but doable. Then, I will have to include some more conditions to determine what kind of video am I serving, Youtube, Dailymotion, etc.. So the code above will have to change, eventually. At least now, I can watch videos in a small window (can size it too, obviously) and can make the apps window stay-on-top while I work or code on the laptop. Something I always wanted to do but didn't know how, until now. What I am thinking next, is how to add URL's to the combobox while the program is running. That idea is tricky to me as I've never done that and don't know how, yet. Then, every time I copy/paste/[Go], the URL is to be checked if in the combobox list, and if not, add it, and if it is already there, ignore it. Something like that, I guess. Anyway, I am already liking this app :)
- 12 replies
-
- delphi xe7
- youtube
-
(and 1 more)
Tagged with:
-
Success!! I was initially trying the built-in TWebBrowser, which failed. And then tried the recommended browser engine alternative for Windows 7 (under XE7) and it failed. But I believe it failed because I do not have that component, the WebView4Delphi (TWVBrowser and TWVWindowParent components) set up correctly and I was not getting a webpage or anything showing in the TWVWindorParent window. Then, I went to the demos folder and tried the SimpleBrowser and that worked, that is, it will show a browser window of anything, say for instance, www.google.com and so on, and all under Windows 7 on my laptop. I use my laptop with win7 as my main work station. I surf the internet and build applications and what-not's. And then after further searches, I found out how to play a Youtube video in a window using the WebView4Delphi browser component alternative (for win 7) without loading the whole youtube webpage. And that is through embeding, and the same for Dailymotion videos, though a bit different, both methods work perfectly. And now, all I need to do is add a few more features.
- 12 replies
-
- delphi xe7
- youtube
-
(and 1 more)
Tagged with:
-
Specs: Delphi XE7, VCL, Windows 7 -- youtube video URL's, to play videos only. I don't know why, but I am struggling with this one, how to create an app to just play youtube videos in. At first, I thought I should be using the TWebBrowser component. But then I thought maybe that is not a good idea because then the whole webpage will show, and that is not what I want. I only want to play video by its URL. Thus, only to show a video window. I have a list of youtube URL's (and also their thumbnail URL's) , so I will use a combobox or listbox control on my form. I would also like to play other website videos, like Vemeo, and Dailymotion, etc. Although I've played around with using the TWebBrowser, that was a fail--for obvious reasons. And i've also tried CEF4Delphi and WebView4Delphi and those two are also not working. So I am thinking I need some other component all-together. What (free) components do I need to accomplish this?
- 12 replies
-
- delphi xe7
- youtube
-
(and 1 more)
Tagged with:
-
Aoc2024Day11 Puzzle Part 1 Okay, so I have finally completed part 1 of this puzzle. As usual, I had a lot of issues to resolve. I believe it to be a working solve. I've added two additional columns, one for the line count, (to know what line you see) and the other is the stone counts. As you can see, the last line, 6, shows 22 stones, just as stated in the instructions. Since I don't use the console projects method, I used the TMemo for this. During the whole processing of this puzzle, I fed off the memo, almost recursive, in a way. So, as I obtained the stones from the lines property of the memo and processed it same, I updated to the next line to obtain the next set of stones, and so on. Anyway, I think it looks good and solved! << fig 1 - AoC2024Day11 >>
-
specs: Delphi XE7, VCL, Win7 laptop -- syncing two memo's scrolling via cursor keys and mouse -- Success #2 !! I was busy in another project these past few days. Uwe's first version works as requested. I did not think to add additional keys and mouse features at the time. Later, someone else asked for further features. Today, I tested the rest of the posted versions from Uwe, and the last one from Kryvich (his post from Monday 7:06am, page 1). Here is my list of what works successfully for scrolling inside the two memo's under Windows 7 using Kryvich's code snippet: * scrolling Up/Down, Left/Right via cursor keys * scrolling Up/Down via PageUp/Down keys * scrolling Up/Down via mouse wheel while clicked inside any of the memo's. * scrolling Up/Down/Left/Right via mouse click-and-dragging up/down on the verticle scrollbars * scrolling Left/Right via mouse click-and-dragging on the horizontal scrollbars In this scenario, the two memo's window or viewing size should be the same. One should not be larger in width, though it may not matter in some cases--I did try it by playing around with the Anchors and re-sizing one of the memo's at runtime. The scrolling will function accordingly, but at some point it will not because it runs out of scrolling space, which makes sense. So, keeping the window size the same for the memo's is beneficial for this feature. What does not work is scrolling Left/Right via mouse wheel via "rolling" the wheel. As far as I can tell, this was not asked about. But this feature is something I used in the good old days of the Opera browser, some 15 or 20 years ago, and then one day they took it out for good. You would press the Ctrl key while spinning the mouse wheel Up/Down in order to go left or right in the browser window. I miss this feature in a browser. The TMemo does not have this feature. But it would sure be nice if it did. The user would move the mouse pointer over the main thick scrollbar (the one inside, between the Left/Right scrollbars) and press and hold the Ctrl key and spin the mouse wheel to scroll left and right in the memo. Actually, if memory serves me, as long as I was in the document section or browser window with the mouse point, I could press and hold down the Ctrl and spinning the mouse wheel. I don't think it had to be on the scrollbar, or maybe it changed and you didn't have to be on the scrollbar anymore. And then they removed that whole feature. My thanks to both Uwe and Kryvich for providing the solutions to this aged old wish, going back to the early 2000's for me. Anyway. I am greatfull !!
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with:
-
update on the sync'ed scrolling of both memos via the cursor UP and DOWN keys when inside a memo. . . using the code from the link I posted earlier, I have the following working to scroll the memo's during cursor up/down inside a memo. I am calling the methods from memo1 only, not added to memo2 for this test demo. To make things a little convenient, below is a short demo project. 1. add two memos controls to a form. (I called mine m1 and m1 to reduce typing). 2. add two statictext controls. (again, I called mine st1 and st2) - I was using them to help me debug where I was at in the memo via the memo.caret.Y position. 3. fill both memos with some text. I added the following in both memos to make things easier, below. 1 line 1 2 line 2 3 line 3 4 line 4 5 line 5 6 line 6 7 line 7 8 line 8 9 line 9 10 line 10 11 line 11 12 line 12 The source code so far. . . unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls; type TForm1 = class(TForm) Panel1: TPanel; Button1: TButton; m1: TMemo; m2: TMemo; Splitter1: TSplitter; st1: TStaticText; st2: TStaticText; procedure m1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function GetVisibleLineCount(Memo: TMemo): Integer; var DC: HDC; SaveFont: HFONT; TextMetric: TTextMetric; EditRect: TRect; begin DC := GetDC(0); SaveFont := SelectObject(DC, Memo.Font.Handle); GetTextMetrics(DC, TextMetric); SelectObject(DC, SaveFont); ReleaseDC(0, DC); Memo.Perform(EM_GETRECT, 0, LPARAM(@EditRect)); Result := (EditRect.Bottom - EditRect.Top) div TextMetric.tmHeight; form1.st1.Caption := result.ToString(); end; procedure TForm1.m1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); var LineCount, TopLine: Integer; begin // sec 1 if key=vk_down then begin st2.Caption := m1.CaretPos.Y.ToString(); LineCount := M1.Perform(EM_GETLINECOUNT, 0, 0) - 1; TopLine := M1.Perform(EM_GETFIRSTVISIBLELINE, 0, 0); if (m1.CaretPos.Y+topline >= GetVisibleLineCount(M1)) then begin SendMessage(M2.Handle, EM_LINESCROLL, 0, 1); end; end; // sec 2 if key=vk_up then begin st2.Caption := m1.CaretPos.Y.ToString(); LineCount := M1.Perform(EM_GETLINECOUNT, 0, 0) - 1; TopLine := M1.Perform(EM_GETFIRSTVISIBLELINE, 0, 0); if (m1.CaretPos.Y <= GetVisibleLineCount(M1)) then begin SendMessage(M2.Handle, EM_LINESCROLL, 0, -1); end; end; end; end. When you run it, and cursor down, when you are on line 8, and cursor down, the second memo will scroll. But, when cursor'ing up, its buggy. I can't seem to figure how to sync the two as yet in { // sec 2 } its just eluding me at the moment, and its late and I'm in a rush to get ready for work. Note, it is not as fluidly smooth/quick as the part that Uwe had posted earlier, but it should get the job done once the bug(s) are resolved. I gave it a shot, but perhaps someone else reading this can figure it out or something else better. visual screenshot demo from design mode, below.
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with:
-
I felt I better try to explain my idea, regarding being inside the memo and cursoring up or down and cusing both memos to scroll in sync: When you are inside the memo and, say, cursor keying down, you want to find the last line that is with-in the memo's window region. So say you have 30 lines of text in the main memo (the left pane) and your window's dimentional region is showing 5 lines of text: (mind you, both memo's have the exact text) 1 2 3 ========================================= 4 this is line 4, I am 4 lines into this memo of 30 total lines. 5 and line 5, okay getting somewhere 6 line 6, getting closer 7 line 7, almost there 8 line 8, I'm here, at the end section of the region, now i want to see lines 9 and onward in this memo and cause the other memo to scroll in sync. ========================================= 9 10 . . 30 end of memo document. You don't want the cursor down key to cause a (down) scrolling to occur while inside that window between line 4 and 7 as you are cursor down'ing, but when you are at line 8 and you press the cursor down key, then you want the scrolling(s) to occur in sync. And the same goes for when you are cursoring up, to not (up) scrolling in sync until you are at 4 and want to scroll into line 3 and so on until you hit line 1 and no scrolling should occur.
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with: