w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Delphi scrolling Memo
You need a condition to decide whether to scroll to the bottom or not. The below seems to work with a simple test, it sums the top most visible line with the number of possible lines that the memo can show to find out if the last line is visible or not. procedure TForm1.Memo1Change(Sender: TObject); var LineCount, TopLine: Integer; begin LineCount := Memo1.Perform(EM_GETLINECOUNT, 0, 0) - 1; TopLine := Memo1.Perform(EM_GETFIRSTVISIBLELINE, 0, 0); if (TopLine + GetVisibleLineCount(Memo1)) >= LineCount then SendMessage(Memo1.Handle, EM_LINESCROLL, 0, LineCount); end; where function GetVisibleLineCount(Memo: TMemo): Integer; var DC: HDC; SaveFont: HFONT; TextMetric: TTextMetric; EditRect: TRect; begin DC := GetDC(0); SaveFont := SelectObject(DC, Memo.Font.Handle

Categories : Delphi

How can I export a voice memo from my app to iPhone's voice memo app?
I think you have to use UIDocumentInteractionController. This way you can provide an "Open In" option on .wav file. My guess is the Voice Memo app has supported file type of .wav extension and you must be able to see that app in Open in option. Refer this link to know how to set up UIDocumentInteractionController.

Categories : IOS

In Delphi XE4 how to access data record after listbox selected with livebindings
There's a Sensor Info demo application from Embarcadero in XE5 Samples directory... There you have OnItemClick = lbMainItemClick in TListBox events then you have to define the event handler: procedure TfrmAboutSensors.lbMainItemClick(const Sender: TCustomListBox; const Item: TListBoxItem); begin if Assigned(Item.OnClick) then Item.OnClick(Item); end; And then for every item on the list: for LItem in LListBox do begin //LItem.ItemData.Accessory := TListBoxItemData.TAccessory.aDetail; // my code //LItem.ItemData.Accessory := TListBoxItemData.TAccessory.aNone; // my code LItem.OnClick := ListBoxItemClick; end; Please give us callback if that helps.

Categories : Delphi

How do I pretty-print JSON in Delphi?
Use the superobject library, make sure that you use the latest version from the repository file, not the 1.2.4 ZIP. Then you can format your TSuperObject object with .AsJSON(true) (the 'true' does the trick). [ Note that you have no control over the order in which the JSON fields are displayed ] [ And to create your object from the string: var lJSON : ISuperObject; lJSON := SO(string); ]

Categories : Json

Can't store array in json field in postgresql (rails) can't cast Array to json
Exec Summary: This is a known issue and is addressed in this pull request, which is awaiting merge as of this writing. Long version: Well, I can see why and how it's failing/succeeding based on Array/Hash. Here's the Rails method that's doing the type conversion (from quoting.rb) and it clearly doesn't support casting from Ruby Array to Postgres json while it does support casting from Hash. Also, I put some debugging code at the beginning of this method and found that it doesn't matter if you use flights or flights.to_json as the value, as the latter gets converted to the former for purposes of this casting. I'm going to do some more digging because I had no problem inserting the value of flights.to_json into a json column using psql. def type_cast(value, column, array_member = fals

Categories : Ruby On Rails

How to store the JSON array inside JSON Array result and display in the listview?
Just create class JsonHolder like this: public class JsonHolder{ int RequestID; String Product; String Currency; String etc... } Then create ArrayList of JsonHolder's objects ArrayList<JsonHolder>data = new ArrayList(); Then just in your circle, where you parse json, after parsing every json array item, create JsonHolder object and add it to ArrayList data. So you will have all your json objects like custom objects and the will be store in ArrayList.

Categories : Java

Delphi Array Initializations
This question has nothing to do with open arrays, so please remove that tag from your question. The bracket syntax you are using declares a Set of values, which is basically a special type of bitmask where each bit corresponds to the value in that position. In other words, [0, 2, 5, 9, 10, 12] is a Set of Integer containing 6 elements, where bit 0 refers to value 0, bit 1 refers to value 2, bit 2 refers to value 5, and so on. A Set cannot be assigned directly to an array like you are attempting to do.

Categories : Delphi

How to Import XML to MS Access with Memo Data Type?
If the Access destination table exists, ImportXML with the acAppendData parameter preserves the structure of that table. It adds the XML data to the table, assuming those data are compatible with the table fields' data types. Create your RelevantResults table with memo data type where you need it, then run ImportXML to fill that table.

Categories : Xml

What is the best way to add a Memo field that will sometimes be Null in a MS Access database?
Lots of NULL values in a string field will have a very minimal impact on the DB SIZE. As a test I Added a String(255) column to a table with ~ 1 Million rows and left all of them NULL. The database grew in size by 44KB before a compact and repair. After a compact and repair, the net impact was 40KB. So, unless you need Many to One relationship between Memo's and the base object, I would leave the field in the main table.

Categories : Ms Access

how to create a credit memo in magento programmatically
You can easily make credit memo from paid invoices. So first you need to get all paid invoices from your order: $invoices = array(); foreach ($order->getInvoiceCollection() as $invoice) { if ($invoice->canRefund()) { $invoices[] = $invoice; } } Then go throughout the invoices and make credit memo: $service = Mage::getModel('sales/service_order', $order); foreach ($invoices as $invoice) { $creditmemo = $service->prepareInvoiceCreditmemo($invoice); $creditmemo->refund(); } Hope it works for you.

Categories : PHP

Pass Listbox Items as array to another pages
You could be using a ViewModel for this. Check out something like MvvmLight. You create an IOC and Service Locator (well, the template will create one for you) which allows you to access your ViewModels from anywhere in your app via Source={StaticResource Locator}.

Categories : C#

Parameterized INSERT with Memo and Text Fields in VBA / MS-ACCESS?
I believe that there are two issues at play here: I'm pretty sure that with the release of Jet 4.0 (and, subsequently, ACE) the required types changed to adVarWChar for Text, and and adLongVarWChar for Memo (for multi-byte character support). Text parameters must have a (maximum) length defined. I don't see those in your .CreateParameter() calls.

Categories : SQL

delphi Copy MemoryStream to Dynamic array
You appear to want to copy the entire stream onto @MyRecord.StreamHolder. Do that like this: Strm.ReadBuffer(MyRecord.StreamHolder, Size); You'll also need to change your GetMem to allocate enough memory. GetMem(MyRecord, Size + SizeOf(MyRecord^) - SizeOf(MyRecord.StreamHolder)); Or perhaps more elegantly: GetMem(MyRecord, Size + Integer(@PMyRecord(nil)^.StreamHolder)); As it stands your code does not take account of that part of the record which appears before StreamHolder.

Categories : Delphi

Delphi. Convert Bitmap image to 2D Array
You can load your image into a TBitmap. Then you can use the ScanLine property of a TBitmap class. This indexed property takes a 0 based index of a row and returns a pointer to pixel values for that row. Take a look at this page to learn more about ScanLine property.

Categories : Arrays

How do I click a button that will remove an item from a ListBox and the List that holds the information for the ListBox in C#?
Your add method calls Add() on a base class. Do you have a remove on your base class? If so, use that. Otherwise change your ShoppingBasket class to be: The Orders list stores your OrderItems. Add and Remove from this list. public class ShoppingBasket { public List<OrderItem> Orders { get; set; } public ShoppingBasket() { Orders = new List<OrderItem>(); } public void Add(OrderItem orderItem) { Orders.Add(orderItem); } public void Remove(OrderItem orderItem) { Orders.Remove(orderItem); } } Usage: var basket = new ShoppingBasket(); basket.Add( new OrderItem { OrderItemId = 1, ... } ); // Remove an OrderItem basket.Remove( new OrderItem { OrderItemId = 1 } );

Categories : C#

Link listBox with Database and show values in textBox if select index in listBox. C#
ideally i would change your listbox to datagridview and change your method like this void fill_listbox() { try { string constring = "datasource=sql2.freesqldatabase.com;port=3306;username=sql217040;password=xxxxx"; string Query = "select * from sql217040.fakedata ;"; using(MySqlConnection conDataBase = new MySqlConnection(constring)) { conDataBase.Open(); using (SqlDataAdapter a = new SqlDataAdapter(Query, conDataBase)) { DataTable t = new DataTable(); a.Fill(t); // Render data onto the screen dataGridView1.DataSource = t; // <-- datagridview1 is the gridview i have added } } } catch(Exception ex)

Categories : C#

Why I always get the first selected value from a ListBox when I call ListBox.SelectedValue and select items in ASC order inC#?
Try using SelectedItem instead: private void lstEquipos_SelectedIndexChanged(object sender, EventArgs e) { // Get the currently selected item in the list box string currentItem = lstEquipos.SelectedItem.ToString(); // Find the index of the currently selected item in the list box int index = lstEquipos.FindString(cucurrentItemItem); textBox1.Text = index.ToString(); }

Categories : C#

ListBox displays "System.Windows.Forms.ListBox.Items.Count..."
To write the items, change the line that does the write to: rollLog.WriteLine(lstBoxOut.items[count]); To read it back in: private void btnReadFile(object sender, EventArgs e) { lstBoxOut.Items.Clear(); foreach (string line in File.ReadLines("Roll Results.txt")) { lstBoxOut.Items.Add(line); } } The reason you're getting that output "System.Windows.Forms.ListBox...." is because the statement rollLog.WriteLine(lstBoxOut) is equivalent to rollLog.WriteLine(lstBoxOut.ToString()). The ToString() method returns A string that states the control type, the count of items in the ListBox control, and the Text property of the first item in the ListBox, if the count is not 0.

Categories : C#

Access SQL Query to split out the Postcode from memo field into new column
This Example is base on a table like below: SELECT Table2.id, IIf([Table2.Address] Is Null,Null,(Right([Table2.Address],Len([Table2.Address])-InStrRev([Table2.Address],Chr(13))-1))) AS PostCode, IIf([Table2.Address] Is Null,Null,(Left([Table2.Address],InStrRev([Table2.Address],Chr(13))-1))) AS RestofAddress FROM Table2; Gives: This Example does assume that the postcode is on the last line, and that all addresses have postcodes.

Categories : SQL

Notify ListBox and ListBox Item for CRUD from Background Thread
To be straight to the point, creating new instance of the ObservableCollection every time your data changes then re-assigning it to the ItemSource, is not only disregarding core purpose of the ObservableCollection, it is also breaking/misusing the concept of Data Binding. //this is the line I am talking about: var Items = new ObservableCollection<Item>(notUploadedItems); Instead, create the ObserbaleCollection once -- make it a property: private readonly ObservableCollection<Item> _items = new ObservableCollection<Item>(); public ObservableCollection<Item> Items {get {return _items;} For the updates use collection's '.Add()' or 'Remove()' methods You're correct that you must be on the UI Main thread to do the updates: DoItOnUIThread(() =>Items.Add(newIt

Categories : SQL

Move and remove Listbox item to another listbox using jQuery in same places
Maybe you can simply set and remove the attribute "disabled" but it will leave a blank space in the options. Note that with this method you will need to clone the option the first time. The other solution whould be to add the content as usual but applying a sort() function before function byValue(a, b) { return a.value > b.value ? 1 : -1; }; function rearrangeList(list) { $(list).find("option").sort(byValue).appendTo(list); } $(function () { $("#button1").click(function () { $("#list1 > option:selected").each(function () { $(this).remove().appendTo("#list2"); rearrangeList("#list2"); }); }); $("#button2").click(function () { $("#list2 > option:selected").each(function () { $(this).remove().appendT

Categories : Javascript

Passing selected value of a listbox to another listbox in google-apps-script
I think that you simply forgot to set a Name to your hidden widget , you only gave an ID... and as you obviously know the event parameter uses the widgets name to get back its value. :-) h = app.createHidden("selectedGrade").setId("selectedGrade").setName("selectedGrade"); EDIT : Oooops, you're right, I didn't notice at first. After playing a bit with your code I found that you where forgeting a callBackElement with your handler, I also added a second hidden widget to hold the course value. Here is a copy of your code in which I replaced the hidden widgets by textBoxes to see what was happening. It seems to work as expected, you can hide the textBoxes when everything is ok or replace them by hidden widgets again. function executionStartsHere() { var doc = SpreadsheetApp.getAc

Categories : Javascript

Delphi dynamic array iteration and record copying
The loop variable of a for/in loop is a copy of the value held by the container over which the loop is iterating. Since you cannot replace the default enumerator for dynamic arrays, there is no way for you to create an enumerator that returns references rather than copies. If you were to wrap up the array inside a record, you could create an enumerator for the record that would return references. Obviously you can use a traditional indexed for loop if you wish to avoid making copies. One might ask, since there appears to be no documentation of the above statement, why the compiler does not choose to implement such for/in loops using references rather than copies. Only the designers can answer that definitely, but I can offer a justification. Consider a custom enumerator. The document

Categories : Delphi

Bizzare Listbox Populating Issue; Listbox will not populate
Ok, I figured out a solution here. After steping through the sub I noticed it wasn't cycling through the open workbooks, so there was some issue where it wasn't grabbing the right instance of excel, but still wasn't creating it's own. As such, I revised one line to late binding: Set ExcelAp = Excel.Application to Set ExcelAp = GetObject(, "Excel.Application") And lo and behold it works. Just thought I'd leave this here for anyone in the future who may search out an answer to this situation.

Categories : Vba

Access 2007: Append data to memo field using a command button
The quickest way I could see to rigging what you already have to what you requested would be to do this: Since you already have a bound memo field for the insertion, just make it invisible. In the onClick event for your command button, you'll just populate that memo field with an InputBox with something like dim cmt as String cmt = InputBox("Please provide a comment.") if cmt = "" then msgbox("Comments cannot be empty") else me.myBoundMemofield = cmt docmd.save

Categories : Vba

How to consume TDatasource Component by coding returned through delphi webservice in a delphi VLC Form
You cannot do that as the TADODataSet cannot be remoted as it would need the TADOConnection and such things like ConnectionString on the client as well as on the server. The way to remove data using Delphi us using DataSnap with a TSoapDataModule on the server side containing a TClientDataSet which gets populated from the TADODataSet using a TDataSetProvider, and a on the client side a TSoapConnection plus TClientDataSet on the client. DataSnap then will perform all the read/update traffic for you using SOAP (i.e. XML over HTTP). See the DataSnap videos from Pawel Glowacki to get an idea on how to set this up, then read the documentation at Creating multi tiered applications Index. Note that for DataSnap, you need to have the Delphi Enterprise as minimum edition, and this won't work wi

Categories : Sql Server

Unable to insert Unicode into SQL Server 2008 using Delphi ZeosLib and Delphi 7
I have not tested your example, but I'm able to save and retrieve from database Unicode characters without problem on SQL Server with Delphi 7 VCL/CLX and zeoslib. I think in your case it will be enough changing your save procedure like this : procedure TForm1.Button2Click(Sender: TObject); var sqlstring : widestring; data : UTF8String; begin FZConnection := TZConnection.Create(Owner); FZConnection.LoginPrompt := False; FZQuery := TZQuery.Create(Owner); FZQuery.Connection := FZConnection; FZConnection.Protocol := 'mssql'; FZConnection.Database := 'replace-with-your-db'; FZConnection.HostName := 'localhost'; FZConnection.User := 'sa'; FZConnection.Password := 'replace-with-your-password'; FZConnection.Connect; data:= UTF8String( utf8encode(tntedit1.Text) ); sqlstr

Categories : Sql Server

How to inherite a custom form (visual inheritance) from delphi Dll in my delphi project
It's not possible to import and use a VCL object from a DLL. When you try to do so you end up with two different instances of the VCL, including two different distinct versions of the imported form type. There's the version in the DLL, and the version in the application. They are distinct, and two versions of the type is one too many. The supported way to import a complex type from another module is to use a package. If you don't want to use packages, then you'll have to use some form of interop that does work across DLL module boundaries. For example, COM interfaces.

Categories : Delphi

Reading double values from a file and storing them in an array then display in listbox
If the file is UTF8 format and contains nothing but floating point numbers one per line, you can parse them all into a sequence like so (in the current locale) var fileNumbers = File.ReadLines(filename).Select(double.Parse); This works because File.ReadLines() returns an IEnumerable<string> which returns each string from the file in sequence. Then I use Linq's Select() to apply double.Parse() to each line, which effectively converts the sequence of strings to a sequence of doubles. Then you can use the sequence like this: int index = 0; foreach (var number in fileNumbers) numbers[index++] = number; Or you can omit the intermediary numbers array and put them straight into the list box: foreach (var number in fileNumbers) outputListbox.Items.Add(number); You could do

Categories : C#

Array of structs questions - how to determine sizeof() manually - Delphi?
It would help if you show the declaration type of the array element, but in case it isn't obvious Array[i] means the i'th array element and thus sizeof(Array[i]) is the size of one element in the array. If the array element is a record (struct) type, then the default is to pad fields so that they start on a natural boundary in relation to their type - a 16-bit int starts at an offset divisible by 2 (16-bits), and so on. If the packed modifier is used in the record declaration (rare) then no such padding is performed. Fields are stored within each record in the order they are declared.

Categories : Delphi

How to find the maximum value in JSON array which also contains some JSON array
Something like this? Math.max.apply(0,points.map(function(v){return v.x})); Still a loop, but it's succinct. Here's how to do it for YValues. A long line though: Math.max.apply(0,[].concat.apply([],arr.map(function(v){return v.YValues})));

Categories : Javascript

how to convert a record to byte array and extract values back in delphi?
You copy with move command length*2 bytes on one side, but length only bytes on other side. If you use unicode strings, then you need to use length*2 bytes on the both sides. Another problem here is that you copy two strings in one array, one by one. If you want to save both strings in one array, then you have to allocate enough of space inside array, also put information about length of strings and write content of both strings. Example how to put 2 strings into 1 array of bytes: procedure test; var len: integer; buf: array of byte; a,b: string; begin a := 'try'; b := 'that'; // save setlength(buf, SizeOf(Char)*(Length(a)+Length(b))+8); len := length(a); move(len, buf[0], 4); len := length(b); move(len, buf[4], 4); move(a[1], buf[8], length(a)*SizeOf(char)); m

Categories : Delphi

Lost TeeChart / TChart in Delphi XE2 when installing Delphi XE4
The design time package for the TeeChart Standard component shipped with XE2 is C:Program Files (x86)EmbarcaderoRAD Studio9.0indcltee9160.bpl. You can install it manually through the "Add..." buton in the list of packages at the "ComponentIsntall Packages..." menu.

Categories : Delphi

How to use modern CPU instructions in Delphi? (Java faster than Delphi?)
How can we use modern CPU instructions in Delphi (without resorting to ASM)? If the compiler won't emit the CPU instructions that you wish to use, then there is no alternative to generating the desired instructions yourself, for example by using the inline assembler.

Categories : Delphi

ListBox in another ListBox in Firemonkey Style Designer
You misunderstood how the TListBox component works and how the StyleLookup property is involved. The only control that the TListBox can host is a TListBoxItem or a descendant of that control. the CustomItem that you refer to is just a name of the Style Object which is apart of a custom FMX style included in the Delphi Firemonkey CustomListBox sample. You can assign a style object to a specific list box item by providing it's name to the StyleLookup property. The item will then visually behave as instructed by that Style Object. What you really are looking for is the FMX.TTreeView component. You can make it behave exactly like the TListBox with the added bonus of Items being able to host child items. I suggest you take a good look at the provided Firemonkey sample.

Categories : Delphi

Listbox inside listbox with binding data
firstly , your approach is not right in place of this you can use collectionViewsource which can be used to implement the grouped data. cause of not binding is because your second Listbox is in Datatemplate of First Listbox so its DataContext is being set to the DataContext of the Parent that is MyDataForTransit and this collection does not contain the collection MyDataForTransit to which your second listBox is Binded so your Second listbox is not Showing anything. For checking this make a collection in your BindingData Class and Bind Second ListBox ItemsSource to this Collection you will Find That it is working. actually in wpf there is property called relativeSource which can be easily set to your class/page/usercontrol but in windows 8 i am not able to do that. hope it will help you s

Categories : C#

How do I bind a listbox to XPath of SelectedItem from another Listbox?
Your DataTemplate should come under <ListBox.ItemTemplate> for the second list. Currently you are setting it directly under it thats why you are seeing the class name.And since you are setting the DataContext directly with a collection, you will have to set ItemsSource={Binding}

Categories : Xml

Save listBox item to another listBox which is in another class
Bind both view elements (the elements you want to be "connected" with each other) to the same ViewModel collection. So if one writes inside the text box, change propagated to the ViewModel collection, so notification spreads among subscribers, so to another view too.

Categories : C#

Hide items in a ListBox when ListBox is disabled
Just add another ListBox to the form and when you disable the first listbox with the elements inside of it, hide it, and then display the other to the user which will essentially be an empty greyed out listbox. Then when you enable the box back, hide the empty one and show the real one. Hope this helps.

Categories : C#

Truncates Long Text/Memo string to 255 characters when it is a primary key field or "Indexed: Yes (no-duplicates) allowed"
As @HansUp stated in the comments, Access (specifically the Jet/ACE db engine) only uses the first 255 characters of a Memo/Long Text field to create its index. Hence, it only uses the first 255 characters to enforce No Duplicates. @HansUp's advice to use a different db engine that provides better support for long strings and Full Text search is probably the best approach, but I understand there are often other considerations that may be limiting you to solving your problem in Access. As such, here is an Access-only approach to solving your problem. This assumes the requirement you listed in the comments is valid; i.e., you need to store unique strings of between 400 and 1000 characters. Alternative 1 Keep your initial Memo/Long Text field: Notes Create four text fields (not Mem

Categories : Ms Access



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.