101

(2 replies, posted in General)

Hello AD,


Try to wrap your conditions when you chain more than one between ( and )

if (frmSalesInv.cBoxSale.checked = True) and        // if it's a DB line
     (frmSalesInv.cbSaleInvDBCR.dbItemID = 0) then

This should hopefully solve your problem .


Cheers


Math

102

(6 replies, posted in General)

Sorry to hack this post, but I got no notice of the 3.4 release.

Was there a post about it ? What's new in this version ?

Cheers


Mathias

103

(4 replies, posted in General)

Hello again Dmitry,


I've tried a few things and ended-up with :

MyItem1 := TMenuItem.Create (Pop);
    MyItem1.Caption := 'Mark Asset as Owned';
    MyItem1.BitMap.Width := 16;
    MyItem1.Bitmap.Height := 16;
    POwned := TPngImage.Create;
    POwned.LoadFromFile('.\icons\TEST\owned.png');
    MyItem1.BitMap.Canvas.Draw(0,0,POwned);
    Pop.Items.Add(MyItem1);
  1. Define width and height of the image

  2. Create a TPngImage

  3. Load PNG from file

  4. Assign PNG to Menu Item


This works fine without error and the PNG image is loaded correctly except... it's not transparent.... sad


Any idea to overcome this "detail" and get the image transparent ?

BMP.Assign(PNG);

does not work because it strips the transparency during the assign process

Ideally, we would do :

PNG.AssignTo(BMP);

Theocratically, this would preserve transparency but I'm not 100% sure.


I'll leave you with that smile


Have a nice day


Mathias

Maybe something like

Form1.Edit1.Text := ReplaceStr(memo_content.commatext,',','|');

Math

105

(3 replies, posted in Script)

Hello,


To add to what Jean just said, I think this is a reserved character and, unless you are trying to create an access key shortcut to your button, I'm afraid you can not use it in the label itself ,as "text".


Math

106

(9 replies, posted in Script)

Hello Derek,


Normally, the Default browser is a Windows registry thing and, unless it is not set (which does not open often), the "openurl(v1+v2);" instruction should work on pretty much any computer.
I've tested on mine, on my wife's and on my daughter's and it worked on the three. But then , they are all Windows 10 so this is not really a relevant test.
SIDE NOTE : if you opt for the "openurl" solution, I suppose you also comment the"map.Show;" instruction in order to avoid opening the map form when not needed ?


Regarding the "web.navigate(v1+v2);" instruction, the TWebBrowser created is relying on TidHTTP (if I remember well what Dmitry said) embedded on MVD and one of it's parameters is "User Agent". This parameter tries to "mimic" the behavior a the set browser to be recognized as such by the server hosting the address/page you try to display.


I've tried this option in your app and have either :

  • gotten a map but with the Google warning saying my browser was working in compatibility mode and that the map would not work correctly

  • gotten a warning window saying I was not using a compatible browser


I'm not sure which UserAgent Dmitry as set by default, but this is a parameter we can not change, just like the Connect.Timeout and so on. Maybe you should ask him and see if he could maybe set the default user agent to a more recent one ?


Not sure this helps a lot


Math

Hello prahousefamily,


The lines contained in a memo are TStrings and this has a property CommaText

Try something like this :

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
var
    memo_content : Tstrings;
begin
    memo_content := Form1.Memo1.Lines;

    Form1.Edit1.Text := memo_content.commatext;
end;

Hope this helped


Have a good weekend


Math

108

(5 replies, posted in Script)

This feature would indeed be really great !!


Any progress on this particular point ?


Math

109

(2 replies, posted in Script)

Hello Dmitry,


I love the second method, the first one needing a SQLQuery.


Thank you sir, for your fast and perfect answer ! smile


Cheers


Math

110

(4 replies, posted in SQL queries)

God... how did I not think about this in the first place... smile


Thanks a thousand times Dmitry, it works !!


Cheers


Mathias

111

(2 replies, posted in General)

Hello Terry,


If no separator specified with group_concat, you will get a list of your fields separated by the default comma.


I don't known what you use a a separator for your currency, but if it as also a comma, you might have problems exploding the resulting strings into its original elements and maybe it's a clue to solve your problem.


You can specify your own separator with :

SELECT group_concat(asset_price,'|') FROM asset WHERE asset_sku IN (16749,16750,16751,16752) AND id_vendor = 1

which gives, on my database :

10.95|12.95|10.95|12.95

Now, the question I have in mind : why would you concatenate fields that you want to add between them in the first place ? Why don't you let the FastReport engine or the calculated field do the math for you ?


Cheers


Math

112

(2 replies, posted in Script)

Hello Dmitry and all MVD fans,


Wether by script or with SQLQuery button, we have the ability to hide one or more columns issued from the query by using the reserved word 'delete_col'.


When delete_col is used on the ID of the record, the tablegrid does not display the ID in the row, but

Form1.tablegrid.dbItemID

still refers to the ID and can be used for another query or function.


My question :

If on a SQLQuery Button I have this query :

SELECT
artist.id,
artist.artist_name,
artist_asset.auto
FROM
artist_asset
INNER JOIN artist ON artist_asset.id_artist = artist.id
WHERE artist_asset.id_asset = {edAID} 
ORDER BY upper(artist_name) ASC  

and this setting for the column names in the Tablegrid :

delete_col,Artist Name,delete_col

how can I still get the value of the "auto" field in the tablegrid (on cell click for example...) ?


Thanks in advance


Mathias

Hello AD,


The thread you pointed out helped me solve my problem. Thanks buddy smile


Cheers


Mathias

114

(4 replies, posted in General)

Thanks Dmitry,


I'll stick with my 32 bits bitmaps then smile


Cheers


Math

115

(4 replies, posted in SQL queries)

Thanks for your answer tcoton.


I tried it first thing this morning, but the result is the same : rows are displayed correctly in the grid, bu the id is lost in the process.


Thanks for trying, I'll find another solution smile


Cheers


Mathias

Hello Dmitry,


When you put a button with property "Show record" on a form and link it with a tablegrid and and second form, when double clicking in the tablegrid, this triggers the Edit action and the second form opens.


Is there a way to prevent this behavior ? I have some actions "OnCellDoubleClick" and I would like to activate the Edit action only on the specific edit button click, and not on cell double click.


Thanks in advance and a good day to all



Mathias

117

(4 replies, posted in General)

Hello Dmitry,

The title says it all, I'd like to be able to use PNG images as icons for my menus.

At the moment I do :

    MyItem2.Bitmap.Width := 16;
    MyItem2.Bitmap.Height := 16;
    BMwanted:= TBitmap.Create;
    BMwanted.LoadFromFile('.\icons\Search16.bmp');
    MyItem2.BitMap.Canvas.Draw(0,0,BMwanted);

This works fine, but handling transparency with bitmaps is a pain in the *** if you see what I mean smile
It's doable but you have to generate the alpha channel and save in 32 bits bitmap... not fun.


I spotted the TCustomImageList in the classes list but failed to use it.


Do you think it would be a lot of work to implement PNG handling ?


Cheers


Mathias

118

(4 replies, posted in SQL queries)

Hello Dmitry,


The normal SQLQuery button works fine. A query like

SELECT
artist.id,
artist.artist_name
FROM
tmp_table
INNER JOIN artist ON artist.id = tmp_table.id1
INNER JOIN vendor ON vendor.id = tmp_table.id3
WHERE tmp_table.flag = 'art'
ORDER BY upper(artist_name) ASC

works fine, and even with 'delete_col, Artist Name' as colums titles, the ID of the record is found without problem


Bu then I needed to fill 1 Tablegrid with the results of 2 queries, so I wrote a query like :

SELECT
artist.id,
artist.artist_name
FROM
artist
INNER JOIN tmp_table ON artist.id = tmp_table.id1

UNION

SELECT
artist.id,
artist.artist_name
FROM
artist
INNER JOIN artist_asset ON artist_asset.id_artist = artist.id
WHERE artist_asset.id_asset = {edAID} 

The results of those two queries in one are displayed as expected in the Tablegrid, this works fine, but the ID of the record (dbItemID) seems to be lots in the process... Clicking in the tablegrid to get the ID gives a result of -1;


Is this due to the use of the UNION in my query ?


Cheers


Mathias

119

(10 replies, posted in General)

Even more optimized smile

last minute modification.

120

(10 replies, posted in General)

Hello guys,


I know this is a bloody old topic, but I needed inspiration for a personal project so I digged this one up.


As a result, here it is optimized as much as I could :

  • no more checkboxes to choose your rating

  • just one image and coordinates linked (x,y) to detect the place of the click

  • also, Tablegrid image is determined from image name as a variable, which results in less code for the Tablegrid image.


Anyway

Wish you all a good day


Mathias

121

(13 replies, posted in General)

Hello AD

Something like this could do it :

procedure frmDetails_edPassword_OnChange (Sender: string);
var
    pass_l : Integer;
begin
    pass_l := length(frmDetails.edPassword.Text);
        if pass_l < 5 then frmDetails.edPassword.Color := $008080FF
        else if (pass_l >= 5) and (pass_l < 8) then frmDetails.edPassword.Color := $0051A8FF
        else if pass_l >= 8 then frmDetails.edPassword.Color := clLime;
end;

Measuring the length of the password on the onChange event of the edit field is one basic approach. If you want to check to composition of the password as well, this is another story smile


Adjust the colors and the steps to your needs.


Hope this helps


Math

122

(2 replies, posted in General)

Thank you very much Dmitry smile

123

(2 replies, posted in General)

Hello Dmitry and all MVD fans


This question has probably already been asked, but I'm not sure.


I've just made a little code correction to an application that I'm distributing, and I noticed that, replacing only
- script.dcu
- settings.ini
- forms.xml

was enough for the previous version to inherit the changes (at least I think, I noticed no bugs).


Furthermore, the two executable (compiled with same MVD version) are the same size. And HEX comparison shows no difference.


Am I missing something or those three files are enough for a small update ?


Will I have to send to the new compiled exe only on an MVD version change ?


Thanks in advance


Cheers


Mathias

124

(2 replies, posted in Script)

Hello tbo and welcome on the forum,


The error you get while trying to reference is normal, even if sad : at the moment, you can not do that with the actual version of MVD.


Is for the actual ClipBrd unit, it is only partially integrated and support only strings (as far as I known).


You can use

someStringVar := ClipboardGet;

to assign the text content of the clipboard to a variable or

ClipboardSet(someStringVar); 

to put some text in the clipboard, but that is pretty much all I achived.



if Clipboard.HasFormat(X) then...

X beeing bitmap, metafile or picture is not implemented yet.


What you can do though, is
- CTRL-C to copy your image
- open the file dialog
- CTRL-V which will paste the path to your image in the file dialog


This will put the image in your DBImage without having to browse to it.


Hope this helps a little


Cheers


Mathias

125

(9 replies, posted in General)

Hello Adam,


I have first to say that, in an accounting software, I would not allow deleting clients and invoices once validated. You could allow archiving them for example (add a boolean field archived for example to the client table).


Now, if you really want to delete records from clients, the normal MVD system will not let you if he finds foreign key constraints.


To my knowledge, the only way to customize the message would be to add an OnClick Event on the delete button with something like :

procedure Form1_Button6_OnClick (Sender: string; var Cancel: boolean);
var
    nb_invoice, client_id : Integer;
begin
    client_id := Form1.tgMainCustomers.dbItemID; //WHAT IS THE CLIENT ID ?
        if client_id < 1 then //IF CLIENT ID < 1 THEN NO CLIENT SELECTED, CANCEL THE DELETE ACTION
            begin
                Cancel := True;
                messageDLG('You need to select a customer if you want to perform a delete action',mtWarning,mbOK,0);
            end
        else if client_id >= 1 then //A CLIENT HAS BEEN SELECTED
            begin
                nb_invoice := SQLExecute('SELECT COUNT(id) FROM Invoice WHERE id_customer = "'+IntTOStr(client_id)+'"'); //HOW MANY INVOICES FOR THIS CLIENT ?
                    if nb_invoice = 1 then //ONLY ONE INVOICE, SINGULAR WARNING
                        begin
                            Cancel := True;
                            messageDLG('You can not delete this customer because he has an invoice attached to his account'+#13#10#13#10+'You first need to delete his invoice.',mtError,mbOK,0);
                        end
                    else if nb_invoice > 1 then //MORE THAN ONE INVOICE, PLURIAL WARNING
                        begin
                            Cancel := True;
                            messageDLG('You can not delete this customer because he has invoices attached to his account'+#13#10#13#10+'You first need to delete his invoices.',mtError,mbOK,0);
                        end;
            end;
end;

If none of the condition tested is met, then the delete action is performed.


Wait for the others to answer, but this is how I do it.


Hope this helps



Mathias