Hi, i have this:
1
2
3
4
5
6
7
8
9
10
11
void __fastcall TERDmarker::openimage21Click(TObject *Sender)
{
TPicture * pct = new TPicture;
Graphics::TBitmap *bmpPicture = new Graphics::TBitmap;
bmpPicture->LoadFromFile(L"person.bmp"); // get rid of l and see what happens
pct->Graphic = bmpPicture;
LecERD->Picture = pct;
}
I would like to know, instead of loading person.bmp, how can i execute a opendialog option so the user can choose what they want....
Thanks in advance
Here is one of possible solutions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <Commdlg.h>
...//you need to change char to wchar_t ("" with L"") if UNICODE is set (or use TCHAR with _T() macro)
void OnButtonOpen()
{
char inFilename[_MAX_PATH];
inFilename[0] = '\0';
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = 0;
ofn.lpstrFile = inFilename;
ofn.nMaxFile = _MAX_PATH;;
ofn.lpstrFilter = "JPEG(*.jpg)\0*.jpg\0Targa(*.tga)\0*.tga\0All(*.*) \0*.*\0";//add bmp ext.
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpstrFileTitle = "Open image";
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(!GetOpenFileName(&ofn))
{
return;
}
bmpPicture->LoadFromFile(ofn.lpstrFile);
...
}
|
Last edited on