I know it is a stupid question, but when changing visual libraries I found a "throuble" with FMX...
My problem is: I need to do my own border, so I set the propriety to Border Style:"None", but the application runs in full screen, also covering the windows toolbar, so I would like a way to resize the application form according to the screen eg.:
mainForm->Height = Screen->Height - 10;
It is possible using VCL, but are there any way to do it using FMX library?
The maximum I conquested with FMX is (I don't know how does it returns values, and the kind of values):
Screen->Size(); // TSize
I've also conquested it now, but I have compiler error:
TSize* Tamanho = new TSize;
Tamanho = Screen->Size();
frmPrincipal->Width = Tamanho->Width;
frmPrincipal->Height = Tamanho->Height - 10;
Error:"E2034 Cannot covert 'TSize' to 'TSize*'"
Finally I've tried to put it on frmPrincipal.h, but the same error:
TSize *Tamanho;
PS.: Other possible solutions to solve the "main problem" are acceptable...
Thanks a LOT!
TScreen::Size() return an actual instance of the TSize struct, not a TSize* pointer. You need to change your code accordingly:
TSize Tamanho = Screen->Size();
frmPrincipal->Width = Tamanho.Width;
frmPrincipal->Height = Tamanho.Height - 10;
Alternatively, you can use FMX's Platform Services framework to access the IFMXScreenService interface directly (this is what TScreen::Size() uses internally):
_di_IInterface Intf;
if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXScreenService), Intf))
{
_di_IFMXScreenService Svc = Intf;
TPoint size = Svc->GetScreenSize().Round();
frmPrincipal->Width = size.X;
frmPrincipal->Height = size.Y - 10;
}
Related
Problem: I need to get PrintDlgEx working for my project, but no combination of options or arguments works for me. It gives E_INVALIDARG for any combinations of options, as the ones I copied from Microsoft samples or other online samples.
Replacing PRINTDLGEX with PRINTDLG and PrintDlgEx with PrintDlg (and eliminating the group of options only from PRINTDLGEX) works fine.
Unfortunately I need PrintDlgEx, because I really need the Apply button, to change printers or property sheet without printing, for design and preview.
Please help me find why I can't get the dialog to show.
Code: while I simplified pieces, like what should happen on successful return, or setting DEVMODE and DEVNAMES, I tried this function exactly, with the same result: Invalid Argument.
#include <QDebug>
#include <QWindow>
#include <windows.h>
void showPrintDialog()
{
// Simplifying the setup: real code passes in a QWidget *
QWidget *caller = this;
// Not returning a value or doing any work. I just want the dialog to pop up for now
// Create the standard windows print dialog
PRINTDLGEX printDialog;
memset(&printDialog, 0, sizeof(PRINTDLGEX));
printDialog.lStructSize = sizeof(PRINTDLGEX);
printDialog.Flags = PD_RETURNDC | // Return a printer device context. Without this, HDC may be undefined
PD_USEDEVMODECOPIESANDCOLLATE |
PD_NOSELECTION | // Don't allow selecting individual document pages to print
PD_NOPAGENUMS | // Disables some boxes
PD_NOCURRENTPAGE | // Disables some boxes
PD_NONETWORKBUTTON | // Don't allow networking (but it show "Find printer") so what does this do ?
PD_HIDEPRINTTOFILE; // Don't allow print to file
// Only on PRINTDLGEX
// Theis block copied from https://learn.microsoft.com/en-us/windows/win32/dlgbox/using-common-dialog-boxes?redirectedfrom=MSDN
// I have tried multiple combinations of options, including none, I really don't want any of them
printDialog.nStartPage = START_PAGE_GENERAL;
printDialog.nPageRanges = 1;
printDialog.nMaxPageRanges = 10;
LPPRINTPAGERANGE pageRange = (LPPRINTPAGERANGE) GlobalAlloc(GPTR, 10 * sizeof(PRINTPAGERANGE));
printDialog.lpPageRanges = pageRange;
printDialog.lpPageRanges[0].nFromPage = 1;
printDialog.lpPageRanges[0].nToPage = 1;
printDialog.Flags2 = 0;
printDialog.ExclusionFlags = 0;
printDialog.dwResultAction = 0; // This will tell me if PRINT
// Rest of options are also on PRINTDLG
printDialog.nMinPage = 1;
printDialog.nMaxPage = 10;
// The only options I really need
printDialog.nCopies = 1;
printDialog.hDevMode = Q_NULLPTR; // which will be better once this works
printDialog.hDevNames = Q_NULLPTR; // which will be better once this works
printDialog.hwndOwner = reinterpret_cast<HWND>(caller->windowHandle()->winId());
// Calling...
int result = PrintDlgEx(&printDialog);
qDebug() << (result == E_INVALIDARG ? "Invalid Argument\n" : "Success\n");
// It always is E_INVALIDARG
// Cleanup
if (printDialog.hDevMode)
GlobalFree(printDialog.hDevMode);
if (printDialog.hDevNames)
GlobalFree(printDialog.hDevNames);
if (printDialog.hDC)
DeleteDC(printDialog.hDC);
}
Platform: Windows 10, latest update;
Qt version: 5.12.7 or higher
(since in VM I have 5.15.1)
The fact that I am running in Qt should be irrelevant, since this is all WIN API, beyond the c++ version (11)
I can make your example work if I remove PD_NONETWORKBUTTON flag.
Please note that while it is documented for PRINTDLGA struct, it is NOT listed in PRINTDLGEXA
NOTE: I did get the same error with that flag.
I'm writing a windows forms application in visual studio with c++ and CLR.
And now, i got the following problem:
I read in a file and save all the important informations in a vector.
With a second step, i convert all items to a CLR array and set this array as DataSource.
array<System::String^>^ PREDEFINED = gcnew array <System::String^>(OP->CIS_Values[OP->selectedCIS]->PREDEFINED_order.size());
for (int i = 0; i < OP->CIS_Values[OP->selectedCIS]->PREDEFINED_order.size(); i++) {
PREDEFINED[i] = msclr::interop::marshal_as<System::String^>(OP->CIS_Values[OP->selectedCIS]->PREDEFINED_order[i]);
}
this->comboBox_header_predefinedtypes->DataSource = PREDEFINED;
this->comboBox_header_predefinedtypes->SelectedIndex = -1;
delete PREDEFINED;
After setting the DataSource, it must be possible to remove it. In C# i can do this with
comboBox.DataSource = null;
but how does it work in C++?
I tried the following cases:
comboBox_header_predefinedtypes->DataSource = NULL;
comboBox_header_predefinedtypes->DataSource = 0;
comboBox_header_predefinedtypes->DataSource = -1;
comboBox_header_predefinedtypes->DataBindings->Clear();
comboBox_header_predefinedtypes->Items->Clear();
I tried it with DataBindings before and after DataSource, but i always get the same exception:
System.ArgumentException: "The complex DataBinding accepts as a data source either IList or IListSource"
How can i fix this issue ?
Thx for help.
In C++ CLR you only need to write:
comboBox_header_predefinedtypes->DataSource = nullptr;
and you don't need to write
comboBox_header_predefinedtypes->Items->Clear();
after removing the DateSource to delete the items.
I have looked at the SDL documentation, and an online tutorial regarding its use, but I must be doing something incorrectly.
SDL_Rect TOP_LEFT_VIEWPORT;
TOP_LEFT_VIEWPORT.x = 0;
TOP_LEFT_VIEWPORT.y = 0;
TOP_LEFT_VIEWPORT.h = HEIGHT / 2;
TOP_LEFT_VIEWPORT.w = WIDTH / 2;
The line after I declare TOP_LEFT_VIEWPORT the compiler says "TOP_LEFT_VIEWPORT does not name a type"
I also attempted copy-pasting the code example from https://wiki.libsdl.org/SDL_Rect and it also received the same error.
Thanks for any responses!
I am Wrting code to capture image from camera.Below is the code I have written.
Here method CapturePhotoToStorageFileAsync doesnot return.
auto MediaCap = ref new Windows::Media::Capture::MediaCapture();
auto ImageProp = ref new Windows::Media::Capture::ImageEncodingProperties ();
ImageProp->Height = 240;
ImageProp->Width = 320;
ImageProp->Subtype = "JPEG";
Windows::Storage::StorageFile^ strFile;
auto res = MediaCap->CapturePhotoToStorageFileAsync(ImageProp,strFile);
res->Completed = ref new AsyncActionCompletedHandler([](IAsyncAction ^action)
{
//action->GetResults();
//action->Start();
///action->Close();
});
res->Start();
Am I missing something here??
Did you want to show UI to the user or just silently capture? The only C++ camera sample I've found uses CameraCaptureUI and CaptureFileAsync - then the operation is getting a StorageFile^ back.
If you're deliberately using CapturePhotoToStorageFileAsync, check your capabiities.
The Issue is resolved
I Added code for
InitializeAsync()
Created file to be used to store image
using
Windows::Storage::StorageFileRetrievalOperation^ CreateFileOp = Windows::Storage::KnownFolders::PicturesLibrary->CreateFileAsync("Test.jpg");
I found Java script article and implemented in c++.
http://code.msdn.microsoft.com/windowsdesktop/Media-Capture-Sample-adf87622/sourcecode?fileId=43837&pathId=1754477665
Ok I have written some basic generic webservices before but I have never tried to consume a 3rd party one.
The one I am trying to consume is
http://opendap.co-ops.nos.noaa.gov/axis/webservices/predictions/wsdl/Predictions.wsdl
I am not getting any results back from this what so ever and cannot figure out why.
More odd is it is not even reaching PredictionsClient_getPredictionsAndMetadataCompleted when I put a break point in the code it doesn't even reach it.
Any suggestions would be greatly appreciated
public void Bouy(double meters)
{
PredictionService.Parameters PredictionParams = new PredictionService.Parameters();
PredictionService.PredictionsPortTypeClient PredictionsClient = new PredictionService.PredictionsPortTypeClient();
GeoCoordinateWatcher gc = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
//gc.Position.Location.Latitude, gc.Position.Location.Longitude
GeoCoordinate myLocation = new GeoCoordinate(27.931631,-82.802582);
foreach (var bl in BouyLocation.GetAll())
{
GeoCoordinate otherLocation = new GeoCoordinate(bl.Lat, bl.Lon);
PredictionParams.beginDate = DateTime.Now.ToString("yyyyMMdd");
PredictionParams.endDate = DateTime.Now.AddDays(1.0).ToString("yyyyMMdd");
PredictionParams.stationId = bl.LocationID;
PredictionParams.timeZone = 0;
PredictionParams.unit = 1;
PredictionParams.dataInterval = 6;
PredictionsClient.getPredictionsAndMetadataCompleted += new EventHandler<PredictionService.getPredictionsAndMetadataCompletedEventArgs>(PredictionsClient_getPredictionsAndMetadataCompleted);
PredictionsClient.getPredictionsAndMetadataAsync(PredictionParams);
double mymeters = myLocation.GetDistanceTo(otherLocation);
if (mymeters < meters)
{
TextBlock DynTextBlock = new TextBlock
{
Name = "Appearance" + bl.LocationID,
Text = bl.LocationName + PredictionResult,
TextWrapping = System.Windows.TextWrapping.Wrap,
Margin = new Thickness(12, -6, 12, 0),
Style = (Style)Resources["PhoneTextSubtleStyle"]
};
DynamicAppearance.Children.Add(DynTextBlock);
this.nearByLocations.Add(new BouyLocationModel() { LocationName = bl.LocationName, LocationID = bl.LocationID, Lat = bl.Lat, Lon = bl.Lon });
}
}
var test = nearByLocations;
}
void PredictionsClient_getPredictionsAndMetadataCompleted(object sender, PredictionService.getPredictionsAndMetadataCompletedEventArgs e)
{
string err = e.Error.ToString();
PredictionResult = e.Result.ToString();
}
Loooking at the code you have here I think that you have used the importing of a ServiceReference to auto build the classes for you?
Unfortunately I have found that this is rather temperamental on WP7 and the only way I actually got it to work was when I connected it to a Microsoft WCF service. Connecting to anything else just doesn't work.
If you do google searches there are various pages talking about the fact it doesn't work and ways around it (which I couldn't get to work).
However, there are ways around it but it isn't as simple as the auto-generated stuff. Basically you do things manually.
Although there are other ways to manually create the web service what I did was follow the information in the following which worked well: http://zetitle.wordpress.com/2010/10/14/using-reactive-extensions-with-webrequest/
You will need to parse the response yourself but XML to LINQ works really well for this.
Hope that helps, or maybe someone will have the solution as it is something I am interested in knowing how to get working too