Jump to content

Tntman

Members
  • Content Count

    76
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Tntman


  1. Hi people. 

    I wanna connect vcl app to sql express server but i have some questions for you about application design pattern ..

    I was doing simple things until now ( click on button perform queries and display results )..

    Basically i was not dividing my code and now a lot of things are in main.pas file..

    I would like to implement some MVC pattern and divide my code because its better practice, more maintainable etc..

    Can somebody give me some simple example how this is done ?


  2. 9 hours ago, Tom Chamberlain said:

    That tutorial is using SQL Lite as an embedded database and is a little different from using something like M$ SQL Server or MySQL where there is another service/process running that you are talking to.  That service could be on your computer or on a server were multiple users are talking to it at the same time over a network.  You can write SQL commands against them all, but the features and syntax for some functionally changes from database to database and some are not even available.

     

    If you want to use SQL Lite you do not need MySQL or M$ SQL Server, you can do everything with FireDAC.  I have never used SQL Lite with FireDAC personally. (sometimes I miss the BDE and dbase days, I think I just aged myself)

     

    Check this comparison for a sample of just three of the free database out there:
    https://www.digitalocean.com/community/tutorials/sqlite-vs-mysql-vs-postgresql-a-comparison-of-relational-database-management-systems
     

    Also check out: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_SQLite_with_FireDAC

     

    Ty for answering, yes i know that sqlite and ms are different but i was talking about approach to both databases.. I just posted this sqlite video because i did not find other for ms access.. 

     

    So basically approach is to make a db file for ms access database and point its location on pc and application will talk to it and perform crud operations 


  3. So can I install on my PC Mysql workbench for example and create DB file and than follow this tutorial -> 

     

    to connect to database ?

     

    Also can I ship my .exe with that DB file to friend so he can use it? I mean i can obviously do that but is this a right way of doing things ?


  4. "tieus" is some IT company from canada, u can find them on linkedin also ... For some reason i cant open their official web site.. Maybe if u can open their site u will find some useful info

    • Like 1

  5. 3 hours ago, haentschman said:

    Hi...:classic_cool:

    The question is...why you want the imho old TSQL instead of FireDAC, UNIDAC, Zeos? :classic_huh:

    I found some delphi job online that says that candidates should know tsql.. I just wanted to check it out, i realized that it's pretty old stuff since there are not many examples online.. 

     

    1 hour ago, Lars Fosdal said:

    Are we talking about MS SQL Server T-SQL - or is there a TSQL class somewhere?

    Regardless of which - I'd say go for FireDAC.

    Yes, im talking about ms sql with t sql.. My bad i did not explained well in my first post.. 

     

    Is there any older method except firedac


  6. Have anyone used Delphi with Tsql ? What are advantages and disadvantages in your opinion ? 

     

    I would like to try Delphi with TSQL but there are no relevant resources to learn online, maybe im googling it wrong but as i can see there are not so many resources to learn from ( with examples etc ) 

     

    Can somebody give me some resources where I can read and learn more about this ? Thank you


  7. I have everything installed on my main PC that you mentioned above ( except VsCode  ) and it work with no problems. I also have a lot of other tools ( php,composer,laravel,swoole,servers apache ngnix, android studio, + a lot of android vm's and more....)  and everything works fine .. I mean if u dont want to risk and u have time install it on separate VM

     

    I never used Chocolate and i installed everything manually ..

     

    Thats all that i can say from my experience, hope it helps 

    • Like 1

  8. 8 hours ago, Rollo62 said:

    I'm afraid you had the ESP8862 in mind, as far as I know the ESP32 boards lay around 5$.
    But  you never know what quality to expect from different suppliers ...

     

    Order amount:

    $ 2.49

     

    this is how much i payed for ESP8862 ( shipping included ). I got it 2 years ago and it is still working fine.. When we talk about arduinos and stuff like that i am always getting cheapest possible components and i never had problems.. One of the reasons why i am getting cheapest possible components all the time is that i am using them just for testing purposes, playing around and learning...

     

    8 hours ago, sjordi said:

    Mhhh,

    I was actually talking about the video component that can display it in your app.

    You get the video signal, but which FMX component you use to show the video?
    Thanks

    Steve

     

    I think that u can make it like client-server app, send converted image ( text ) over socket and display it in ur app.. U can display it in normal image component 

     

     

     

     

     

     

     

    • Like 1

  9. 13 hours ago, sjordi said:

    How do you get video streaming?
    Are you using a special FMX tool?

    U can use cheap simple arduino for 2$ that can connect on wifi network and communicate over websockets, try searching for "esp32 websocket" .. that could be one of the solutions 


  10. Are you saying that we could use SVG images in our delphi apps ? Wow this is great, i am having destop app that have really heavy user interface, i am struggling with making different size of images ( png and jpg ) images so it can look nice on my app.. SVG will solve everything, i will try it very soon 


  11. 1 hour ago, aehimself said:

    This is something we (almost) all can relate to. Which makes me wonder... how many of us wrote our own password managers, instead of using an existing one? How many "fun projects" we have ready which are never used/published because we used it only to gain experience?

     

    ...or is it just me?

    Lol its not only you .. i can say that i am pretty crazy when we talk about that.. i am even making android cameras for my phone ( i mean its well known fact that every android have default camera app ) but its just so interesting 😄


  12. 1 hour ago, Remy Lebeau said:

    That information is accessible via webcam APIs.  You don't need VCL or FMX for that.

    I know but win api is too difficult for me, but i need to learn it eventually ..

     

    1 hour ago, Remy Lebeau said:

    Or, you could simply take the screenshot using an in-memory GDI bitmap, and then copy the raw pixel data from that bitmap into an FMX TBitmap as needed.  Look at CreateCompatibleDC(), CreateCompatibleBitmap(), GetObject(), and TBitmap.Canvas.MapBitmap()/UnmapBitmap().

    I did not even know that this exist, it is really interesting i will definitely take a look into it, thanks

     

    BTW, do you know why we have such a difference in size when SS is saved? 

     

    Here is the code :

     

    procedure unasit3();
    var
      DCDesk: hdc;
      bmpVCL, test: VCL.Graphics.TBitmap;
      bmpFMX: FMX.Graphics.TBitmap;
      // bmpVCL -> MS -> MS -> bmpFMX
      MS: TMemoryStream;
    begin
      bmpVCL := VCL.Graphics.TBitmap.Create;
      bmpVCL.PixelFormat := pf4bit;
      bmpFMX := FMX.Graphics.TBitmap.Create;
    
      MS := TMemoryStream.Create;
    
      bmpVCL.Height := Screen.Height;
      bmpVCL.Width := Screen.Width;
    
      DCDesk := GetWindowDC(GetDesktopWindow);
      BitBlt(bmpVCL.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, DCDesk, 0,
        0, SRCCOPY);
    
      bmpVCL.SaveToStream(MS);
      MS.Position := 0;
      bmpFMX.LoadFromStream(MS);
    
      bmpFMX.SaveToFile('unit3FMXBITMAP.png'); 
      bmpVCL.SaveToFile('unit3VCLBITMAP.png');
      bmpVCL.Free;
      bmpFMX.Free;
      MS.Free;
    end;

    VCL Bitmap have 1.31 MB

    FMX Bitmap have 79 KB 

     

    Thats size on disk .. When I open images they look 100% the same , i cant see the difference in quality  even if i zoom in .. is there any explanation for that strange behavior ?


  13. I reorganized my code, im now explicitly assigning values from different units. For example bitmapVCL : vcl.graphic.bitmap... Bitmapfmx : fmx.graphic.bitmap and so on... And it is working perfectly fine..

     

    I think i will not have errors in my program if i am not adding visual components like memo from vcl and memo from fmx 

     

    But i will consider learning/remaking units.. 

     

     


  14. 1 hour ago, Cristian Peța said:

    Accessing camera has nothing to do with VCL or FMX. It should be feasible to copy what FMX.Media.TCameraComponent is basically doing (trimming all the FMX part) and make you own simple component for VCL.

    At least that's what I would do.

    I was thinking the same, but isn't a delphi compiler doing that behind the scenes ? ( trimming unused code ) ?


  15. 4 hours ago, David Heffernan said:

    Wouldn't it just be easier to detect the webcam without trying to mix FMX into the system?

    IT is too difficult for me to figure out and understand code  samples that i found on the internet for accessing webcamera on windows ( VCL ) .. 

    I am making some sort of twitch bot/streaming application where i plan to exchange data bettwen users and twitch API + Twitch IRC . In my app i want to have feature for user ( streamer ) to have a nice preview what options he have on his camera ( resolution,fps etc ), also I want to add some features like taking a screenshot of his game that he is playing or whole screen,

     

    I have 3 options, to make FMX or VCL app.

     

    If i want to make FMX app it will be tricky to take screenshot of particular window or whole screen with fmx due to fmx.bitmap nature.. I basically cannot assing bitmap.canvas.handle when i want to take a screenshot.

     

    Quote

    DCDesk := GetWindowDC(GetDesktopWindow);
      BitBlt(bmpVCL.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, DCDesk, 0,
        0, SRCCOPY);

    this piece of code is impossible if using bmp from FMX.Graphics. So i have to take screenshot with VCL.Graphics.. SO  that means that i am using VCL units in my FMX project ( Mixing again .... )

     

    Other option is to make VCL app that will do screenshot as it usually do with VCL.Graphics bitmap. And to use FMX.Media for accessing webcam properties .. ( Mixing again ... )

     

    Third option is to Make VCL app and LEARN how to access camera options in VCL <- Hardest part ( not mixing fmx and vcl ) .... I guess that third option is best way to go and I think that i should try to re-learn and figure out how code that I found online works.. 


  16. Hi, I am making VCL app but I am mixing FMX units in it. Reason why I am mixing FMX units is that i wanted to detect if webCamera exist, I am using this tutorial ( official embarcadero sample )  to detect it and display useful information ( resolution and fps options ) that camera have:

     

    http://docwiki.embarcadero.com/CodeExamples/Rio/en/FMX.CameraComponent_Sample

     

    This example works fine even in VCL app, but there are some errors and warnings that i am getting when compiling application.. Again, I have to say that it compile with success and it works im just wondering is there any way to fix this issues and warning and should i do ( approach this ) differently ?

     

    I know that it is bad to mix VCL and FMX , but unit "FMX.MEDIA" is such a nice unit that gives me a lot of nice features and i cant see similar unit in VCL...

    I have to mention that I am actually not mixing VISUAL components on form, I am just using only VCL components with FMX.Media unit and methods from it..

     

    Here is error pic: It basically says that it is keeping FMX resources and discarding VCL one

    wsertegrtgrtrtg.thumb.png.409a7db35bca477dd084cb003f31d344.png

     

    Also I have to say that when i comment FMX.Media unit and other places where I am using its code i stop receiving warnings during compiling.. It is obvious that those warnings are because i used FMX.Media unit..


  17. If you are using third party api read the docs there.. They will maybe tell you how much requests are you allowed to send in some amount of time.. Also when you get response from server in 99% of cases they will return amount of requests that you have left to perform in some amount of seconds.. Best way is to use program called postman to simulate requests and see whats going on, it will give you detailed information about everything.. My answer is maybe not what you are looking for but i think that postman will help you to understand better what's actually happening instead of using delphi code to figure out.. After successful tests in postman you implement and write delphi code, that's how i am doing usually 


  18. My application is connecting on twitch irc and reading msgs from there.. Its not from DB so it is more dynamic, admins on twitch irc can delete some message or users can delete so i have to update particular frame if message is deleted... Thats why i am using frames with name so i can figure out what to delete or edit... I think we are not talking about same frame types, i am using this type of frames :  

     


  19. Your answer was really helpful, i almost finished my example today but i can see that i will edit it tomorrow based on your post.. 

     

    5 hours ago, aehimself said:

    Based on your luck, you can leak 10 TListBoxItem obects with one run. Don't do this.

    This is something that i did just for demo to see what will happen if i load 'n' amount of messages ( frames) 'at the same time', basically just for testing purposes to see how fast it will perform and to simulate message received.. 

     

    5 hours ago, aehimself said:

    If you really like With that much, you can just say

    
    With TFrame1.Create(Self) Do
     Begin
      Name := IntToStr(randNumb);
      [...]
     End;

    I did not know that I could do this, it really saves time and boost performance knowing that i will have 2k messages for example ( looping over 2k frames) i will edit that part in my code based on your advice.. 

     

    5 hours ago, aehimself said:

    SetLength(myArray, Length(myArray) + 1)

    In my first post i mentioned this that it looks bad way of doing things so i just abandoned this idea

    5 hours ago, aehimself said:

    oooor instead of an array you can say

    
    messageList: TObjectList<TListBoxItem>;
    [...]
    messageList := TObjectList<TListBoxItem>.Create(True);

    This looks interesting but as I said i think i dont need array of anything in this case because when i add Tframe ( message ) component dynamically on listbox i will give a new tframe component name of message ID, so basically i will never get error that component with particular name already exists because ID's are all different.. . When removing message im just grabbing component name ( tframe name) and performing a look ( looping to find that frame in listbox) and after that i am performing disposeOf. 

    5 hours ago, aehimself said:

     

    P.s.: Is there a purpose you are naming dynamically created objects?

    Well my gui that i made is really intensive and i decided to use frame to represent a message in chat room, so when new message arrives i am creating new tframe ( message) and attaching it to parent listbox, if i dont name it or if i name 2 components with same name im getting error so that is why i am giving unique name to every tframe component


  20. Thank you for your answers i enjoyed reading them 🙂

     

    Looks like that I made problem without problem. I overcomplicated everything for unknown reason ... IN short, my app receive messages and user can delete them. Every message have parent listbox and every message is basically custom looking frame that i made. So simply when use receive new message I am creating new frame that will have Listbox as a parent and frame name will be message_id. That way i will not have errors because every frame will have unique name ( message_id ). When user deletes message I am just simply looping frames and if that particular frame exists i am removing it. 


  21. I am using delphi fmx for windows 10. I have listbox that will have list of messages. every message is inserted in that list box as a fmx frame. I decided to use this as a frame because I can get more nicer GUI look.

    I am simulating creating and deleting messages ( Frames ) by clicking on buttons. So I am basically making front end of the application and I want to make it good working before i actually hook it to internet.

     

    I am trying to practice oop and good design patterns so that is why i want to share with you how i did all this so you can give me suggestions how to improve.

     

    So I have listbox, when i click button1 i am triggering this code that will add 10 messages ( 10 frames ) to a listbox.

    for i := 0 to 10 do
      begin
     randNumb := Random(9900);
        messageList[randNumb] := TListBoxItem.Create(Self);
        messageList[randNumb].Parent := ListBox1;
        messageList[randNumb].Selectable := False;
        TFrame1.Create(Self).Name := IntToStr(randNumb);
        with TFrame1(FindComponent(IntToStr(randNumb))) do
        begin
          Parent := messageList[randNumb];
          //Frame ID is public int property in Frame unit, i will need it later when I am deleting message ( frame )
          frameId := randNumb;
          Label1.Text := 'Message body';
          LabelName.Text := 'John Doe';
          Country.Images := ImageList1;
        end;

    MessageList represents public property ->  MessageList : Array [0 .. 9900] of TListBoxItem; I set array size from 0 to 9900... randNumb presents random number ( index ) that will be given to every messsage ( frame )

    Property frameId have same value as name of the frame that i am creating dynamically.

     

    When I want to delete message ( frame ) I first click on the frame. When I click on the frame I am triggering OnClick event that is located in Frame unit, after that I am deleting message ( frame ) by using "DisposeOf". I have noticed that i also have to call "DisposeOf" not just on frame, i have to call it on MessageList also. So i am also doing MessageList[frameId].DisposeOf;   and frame is deleted , also item in MessageList is deleted.

     

    **********************

    Everything so far that I wrote is working but it does not feel right... 

    1. I want to add new message ( frame ) with an ID that is incremented by 1 compared to biggest index in my array. SO if i have 10 messages , when I add next message I want that message index to be 10+1 =11..

    2.Lets say that i have 10 messages , and i delete message with index of 5. What will happen with other message indexes ? is my MessageList array going to shrink or it will just leave empty space where is index 5 ? Will message that had index 6 before deleting message 5 go and drop down for one place and have index 5 ? will message with index 7 drop on 6th place and so on... ?

    3.I could possibly make MessageList array with unknown length and everytime when i want to add new message i can check length of MessageList array and resize it for +1 and add that item on the end.. but still i have feeling that this is not a way to make this ...

     

    I was reading this : https://stackoverflow.com/questions/433221/how-do-i-declare-an-array-when-i-dont-know-the-length-until-run-time

     

    Third message says  " If your array is no longer static, you might want to consider using a TList, a TStringList or one of the many container classes in the Contnrs unit.

    They may better represent what you are doing, provide additional capabilities you might need, e.g. sorting or name/value pairs, they dynamically grow as you need them, and have been very well optimized. "

     

    So my conclusion about this is that I have to find some correlation between TList or TStringList that i have to create and  MessageList : Array [0 .. 9900] of TListBoxItem that I already created because my list of messages ( Frames ) will grow and shrink dynamically and I dont want to manually figure out how to do it.. I am not sure, maybe my whole concept is wrong from beginning 

     

    Thank you for your help

     

     

×