I have read this article:
Article
It clearly shows hyperlinks are supported in the footer. I can’t work out how to do it. I don’t want a literal URL in the text but other text that hyperlinks to a help article in the program.
This works:
#include "stdafx.h"
#include "CMyTaskDialog.h"
IMPLEMENT_DYNAMIC(CMyTaskDialog, CTaskDialog)
CMyTaskDialog::CMyTaskDialog(_In_ const CString& strContent,
_In_ const CString& strMainInstruction,
_In_ const CString& strTitle,
_In_ int nCommonButtons,
_In_ int nTaskDialogOptions, _In_ const CString& strFooter)
: CTaskDialog(strContent, strMainInstruction, strTitle, nCommonButtons, nTaskDialogOptions, strFooter)
{
}
CMyTaskDialog::~CMyTaskDialog()
{
}
HRESULT CMyTaskDialog::OnHyperlinkClick(const CString& strHref)
{
HWND hwnd =
HtmlHelp(
GetDesktopWindow(),
_T("d:\\MeetSchedAssist.chm::/") + strHref,
HH_DISPLAY_TOPIC,
NULL);
return S_OK;
}
However, there are two issues still:
CTaskDialog does not have a GetSafeHWnd API call so I don't know how to set it as the parent.
The OnHyperlinkClick is generic so if you have multiple links on the task dialog you might have to test the phrase to decide how you want to handle it.
Related
I am using a biometrics SDK. And I converted the headers to delphi to consume the dll.
It looks something like this:
const
{VrBio_EventType}
VRBIO_CAPTURE_EVENT_UNPLUG = $001; {Fingerprint scanner unplugged from the computer.}
VRBIO_CAPTURE_EVENT_PLUG = $002; {Fingerprint scanner plugged on the computer.}
VRBIO_CAPTURE_EVENT_REMOVED = $004; {Finger removed from the fingerprint scanner.}
VRBIO_CAPTURE_EVENT_PLACED = $008; {Finger placed on the fingerprint scanner.}
VRBIO_CAPTURE_EVENT_IMAGE_FRAME = $10; {A fingerprint frame was captured on the fingerprint scanner.}
VRBIO_CAPTURE_EVENT_IMAGE_CAPTURED = $020; {A fingerprint image was captured on the fingerprint scanner.}
VRBIO_CAPTURE_EVENT_FAKE_FINGER_DETECTED = $400; {A false finger has been detected on the sensor}
VRBIO_CAPTURE_EVENT_FAKE_FINGER_REMOVED = $800; {A false finger has been removed from the sensor}
type
(* Stores the parameters of the ISO 19794-4 image format. #see VGetReaderProperties #see VrBio_ReaderProperty
typedef struct
{
/** #see VrBio_ISO197944CompressionMode*/
int compressionMode;
/** #see VrBio_ISO197944ImpressionType*/
int impressionType;
/** #see VrBio_ISO197944FingerPosition*/
int fingerPosition;
}VrBio_ISO197944Parameters;
*)
PISO197944Parameters = ^TISO197944Parameters;
TISO197944Parameters = record
compressionMode: Integer; { #see VrBio_ISO197944CompressionMode}
impressionType: Integer; { #see VrBio_ISO197944ImpressionType}
fingerPosition: Integer; { #see VrBio_ISO197944FingerPosition}
end;
(* Represents a biometric image. #see VrBio_CaptureEventCallback \ref VSyncCapture
struct VrBio_BiometricImage
{
/** Image width.*/
int width;
/**Image height*/
int height;
/**Image resolution in dpi. For the obsolete functions, use pixels/cm.*/
int resolution;
/**Number of channels in the image. Fingerprint images should always be grayscale, so this value is always 1.*/
int channels;
/**Biometric modality.
* Always use VRBIO_BIOMETRIC_MODALITY_FINGERPRINT.
* \ref VrBio_BiometricModality.
*/
int biometricModality;
/**Scanner type.
* \ref VrBio_ScannerType.
*/
int scannerType;
/**Formato de imagem: Formato da imagem.
*\ ref VrBio_ImageFormat.*/
int imageFormat;
/**Size of the buffer*/
int bufferSize;
/**Compression rate. Valid for images that allow compression.
* \ref VrBio_CompressionRate
*/
int compressionRate;
/**Quality of the fingerprint image.
* \ref VrBio_FingerQuality
*/
int fingerQuality;
/** Only valid if the image if imageFormat is \ref VrBio_ImageFormat::VRBIO_IMAGEFORMAT_ISO19794_4
*\ref VrBio_ISO197944Parameters
*/
VrBio_ISO197944Parameters* ISO197944_parameters;
/** Buffer storing the pixels of the image.
The position(x,y,c) of a pixel is y*width*channels+x*channels+c.
*/
unsigned char* buffer;
/**Reserved for future use*/
void* reserved;
};
typedef struct VrBio_BiometricImage VrBio_BiometricImage;
*)
PBiometricImage = ^TBiometricImage;
TBiometricImage = record
width: Integer; { Image width. }
height: Integer; { Image height }
resolution: Integer; { Image resolution in dpi. For the obsolete functions, use pixels/cm.}
channels: Integer; { Number of channels in the image. Fingerprint images should always be grayscale, so this value is always 1. }
biometricModality: Integer; { Biometric modality. Always use VRBIO_BIOMETRIC_MODALITY_FINGERPRINT. \ref VrBio_BiometricModality. }
scannerType: Integer; { Scanner type. \ref VrBio_ScannerType. }
imageFormat: Integer; { Formato de imagem: Formato da imagem. \ ref VrBio_ImageFormat. }
bufferSize: Integer; { Size of the buffer }
compressionRate: Integer; { Compression rate. Valid for images that allow compression. \ref VrBio_CompressionRate }
fingerQuality: Integer; { Quality of the fingerprint image. \ref VrBio_FingerQuality }
ISO197944_parameters: PISO197944Parameters; { Only valid if the image if imageFormat is \ref VrBio_ImageFormat::VRBIO_IMAGEFORMAT_ISO19794_4 \ref VrBio_ISO197944Parameters }
buffer: PByte; { Buffer storing the pixels of the image. The position(x,y,c) of a pixel is y*width*channels+x*channels+c. }
reserved: Pointer; { Reserved for future use }
end;
(*
#include "VTypes.h"
#ifdef WIN32
#define DLLIMPORT extern "C" __declspec(dllimport) int __stdcall
#else
#define DLLIMPORT extern "C"
#endif
*)
{ Callback function that receives events..
typedef void (*VrBio_CaptureEventCallback) (
int eventType,
const char* readerName,
VrBio_BiometricImage* image,
const void* userData)
}
TCaptureEventCallback = procedure(eventType: Integer; readerName: PAnsiChar; image: PBiometricImage; userData: Pointer); stdcall;
{ Function responsible for initializing the SDK. This function MUST be called before calling any other method, except \ref VInstallLicense
DLLIMPORT VStartSDK(VrBio_CaptureEventCallback eventCallback);
}
function VStartSDK(eventCallback: TCaptureEventCallback): Integer; stdcall;
{ Function responsible for finalizing the SDK. This function should be called when the SDK is not needed in the application anymore.
DLLIMPORT VStopSDK();
}
function VStopSDK(): Integer; stdcall;
{ Function responsible for starting the capture on a specific fingerprint reader.
After calling this function, the application is able to receive events.
DLLIMPORT VStartReader(const char* readerName);
}
function VStartReader(readerName: PAnsiChar): Integer; stdcall;
Using it looks like this:
implementation
{$R *.dfm}
procedure EventCallback(eventType: Integer; readerName: PAnsiChar; image: PBiometricImage; userData: Pointer); stdcall;
begin
case eventType of
VRBIO_CAPTURE_EVENT_UNPLUG: Form1.Memo1.Lines.Add('Leitor desconectado!');
VRBIO_CAPTURE_EVENT_REMOVED: Form1.Memo1.Lines.Add('Dedo removido!');
VRBIO_CAPTURE_EVENT_PLACED: Form1.Memo1.Lines.Add('Dedo detectado!');
VRBIO_CAPTURE_EVENT_IMAGE_FRAME: Form1.Memo1.Lines.Add('Frame capturado!');
VRBIO_CAPTURE_EVENT_IMAGE_CAPTURED: Form1.Memo1.Lines.Add('Imagem capturada!');
VRBIO_CAPTURE_EVENT_FAKE_FINGER_DETECTED: Form1.Memo1.Lines.Add('Dedo falso detectado!');
VRBIO_CAPTURE_EVENT_FAKE_FINGER_REMOVED: Form1.Memo1.Lines.Add('Dedo falso removido!');
VRBIO_CAPTURE_EVENT_PLUG:
begin
VStartReader(readerName);
Form1.Memo1.Lines.Add('Leitor conectado!');
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
VStartSDK(EventCallback);
end;
My questions:
I can use the application and get the Plug, Unplug and Placed events, but when I get the Image Captured event I have an acces vilation.
In the events that are working the EventCallback parameter image is nil. Is the TBiometricImage record conversion correct?
How can I convert the TBiometricImage buffer to a TBitmap and display the captured image in a TImage?
when I get the Image Captured event I have an acces vilation. In the events that are working the EventCallback parameter image is nil. Is the TBiometricImage record conversion correct?
The individual fields are declared fine, but double check that the alignment and padding of your Delphi records match the same alignment and padding used by the structs in C/C++.
Also, more importantly, the VrBio_CaptureEventCallback typedef in C/C++ is declared without any calling convention specified, so it will use the compiler's default convention, which is usually __cdecl instead of __stdcall (can be configured in the compiler settings). In Delphi, you declared TCaptureEventCallback to use stdcall instead of cdecl. You have to make sure you match the calling conventions correctly (the exported DLL functions do use stdcall, so you are OK there).
How can I convert the TBiometricImage buffer to a TBitmap and display the captured image in a TImage?
The SDK documentation does not explain how to process the various image formats. However, just looking at the struct declaration, the buffer field points at the actual image data, and the imageFormat field indicates the format of that data (there is a VrBio_ImageFormat enum that you have not translated yet). So, you would have to look at the imageFormat first to know how to interpret the buffer.
I do see a VConvertImage() function available. So you should be able to convert images to BMP format, if they are not already. Based on the samples in the SDK, it looks like the buffer data might be a standard BMP file format, so you could try copying the buffer to a TMemoryStream and then use the TBitmap.LoadFromStream() method.
There are also GIF and JPG image formats available, which could be handled by TGIFImage and TJPEGImage, respectively, or even TWICImage, if you wanted to display scanned GIF/JPG images without having to convert them to BMP first. There is also a RAW image format available (which apparently your images are using), but there is no standard VCL TGraphic class to handle RAW images, but I think there might be some 3rd party classes floating around if you look around.
Otherwise, you might try converting the image data to BMP, if needed, and then pass the buffer to the Win32 API CreateBitmap/Indirect() or CreateDibSection() function, and then assign the resulting HBITMAP to the TBitmap.Handle property if successful.
As usual, every new release of c++ builder takes days of changes...
I'm having trouble fixing a property editor, the code is:
***************** THE H FILE ****************************
//---------------------------------------------------------------------------
#ifndef ufrmLabelEditorH
#define ufrmLabelEditorH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.Buttons.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <DesignIntf.hpp>
#include <TypInfo.hpp>
#include <DesignEditors.hpp>
#include <Classes.hpp>
// Add DesignIDE.bpi to your package's Requires list in the Project Manager
#pragma comment(lib, "DesignIDE.bpi")
//---------------------------------------------------------------------------
class TfrmLabelEditor : public TForm
{
__published: // IDE-managed Components
TPanel *Panel1;
TMemo *Memo1;
TBitBtn *BitBtn1;
TBitBtn *BitBtn2;
private: // User declarations
public: // User declarations
__fastcall TfrmLabelEditor(TComponent* Owner);
};
class PACKAGE TLabelProperty : public TStringProperty
{
public:
virtual Designintf::TPropertyAttributes __fastcall GetAttributes() {
return TStringProperty::GetAttributes()<<paDialog;
}
virtual void __fastcall Edit(void) {
TfrmLabelEditor *frmEditor = new TfrmLabelEditor(Application);
frmEditor->Memo1->Lines->Text = GetStrValue();
try {
if (frmEditor->ShowModal()==mrOk) {
int i;
for (i = 0; i < PropCount; i++) {
((TLabel*)GetComponent(i))->Caption = frmEditor->Memo1->Lines->Text;
}
Modified();
}
} catch (...) {
}
frmEditor->Free();
}
};
//---------------------------------------------------------------------------
extern PACKAGE TfrmLabelEditor *frmLabelEditor;
//---------------------------------------------------------------------------
#endif
************** THE CPP FILE *************************
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ufrmLabelEditor.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfrmLabelEditor *frmLabelEditor;
//---------------------------------------------------------------------------
__fastcall TfrmLabelEditor::TfrmLabelEditor(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
namespace Labelproperty {
void __fastcall PACKAGE Register()
{
TTypeInfo* typeInfo = new TTypeInfo();
typeInfo->Name = "AnsiString";
typeInfo->Kind = tkLString;
Designintf::RegisterPropertyEditor(typeInfo,__classid(TfrmLabelEditor),"Caption", __classid(TLabelProperty));
TComponentClass classes[1] = {__classid(TfrmLabelEditor)};
RegisterComponents(L"SGM", classes, 0);
}
}
Both files are part of a design time only c++ package....
Any help? If not, please tell me about some c++ ide that realy works!!!!! THANKS.....
Your Register() function relies on an unnecessary hack to fake AnsiString RTTI. Not only that, but the VCL uses Unicode strings in XE6, so unless your Caption property is actually declared as AnsiString then your property editor will not register correctly.
Let the property itself provide the correct RTTI to you. The RegisterPropertyEditor() documentation even demonstrates this. This approach works in every version of C++Builder (and Delphi):
void __fastcall PACKAGE Register()
{
PPropInfo pProp = GetPropInfo(__typeinfo(TfrmLabelEditor), "Caption");
RegisterPropertyEditor(*(pProp->PropType), __classid(TfrmLabelEditor), "Caption", __classid(TLabelProperty));
TComponentClass classes[1] = {__classid(TfrmLabelEditor)};
RegisterComponents(L"SGM", classes, 0);
}
Update: That being said, this registration will never work, because you are setting the second parameter of RegisterPropertyEditor() to the wrong value.
TfrmLabelEditor is itself implemented and exists only in a design-time package. By setting the second parameter to TfrmLabelEditor, the Object Inspector will invoke TLabelProperty only when an instance of TfrmLabelEditor is active in the Form Designer and its Caption property is edited in the Object Inspector. But the Form Designer will never see instances of TfrmLabelEditor in projects, so the Object Inspector will never invoke your TLabelProperty editor. That is why you don't see anything happen.
Read the documentation more carefully. The second parameter specifies a specific runtime component type, or NULL for all component types, that have the specified property of the specified property type. TfrmLabelEditor does not qualify for that.
A little adaptation of REMY SOLUTION have worked, not sure why:
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TfrmLabelEditor)};
//********* register my editors ******************
PPropInfo PropInfo = GetPropInfo(__typeinfo(TForm), "Caption");
Designintf::RegisterPropertyEditor(*(PropInfo->PropType),NULL,"Caption", __classid(TLabelProperty));
//*************************************************
RegisterComponents(L"SGM", classes, 0);
}
I have written a class for reading and writing PPM files (don't ask, I didn't chose this format). I would like it to be a part of the TBitmap loading/saving system.
Does any one know how I can add this support? Do I really have to write/install a full codec?
SOLUTION:
With Remy Lebeau post I managed to write and register a codec. However all the needed functions aren't documented so It needed some trial/error to get it to work.
To register the new codec you need to use the static member RegisterBitmapCodecClass of TBitmapCodecManager like this.
TBitmapCodecManager::RegisterBitmapCodecClass(".ppm","portable pixmap",true,__classid(TMyCodec));
The codec need these functions to be defined:
class TMyCodec : public TCustomBitmapCodec {
public:
bool __fastcall LoadFromStream(System::Classes::TStream* const AStream, Fmx::Surfaces::TBitmapSurface* const Bitmap);
bool __fastcall LoadFromFile(const System::UnicodeString AFileName, Fmx::Surfaces::TBitmapSurface* const Bitmap);
bool __fastcall SaveToFile(const System::UnicodeString AFileName, Fmx::Surfaces::TBitmapSurface* const Bitmap, const PBitmapCodecSaveParams SaveParams = (PBitmapCodecSaveParams)(0x0));
bool __fastcall SaveToStream(System::Classes::TStream* const AStream, Fmx::Surfaces::TBitmapSurface* const Bitmap, const System::UnicodeString Extension, const PBitmapCodecSaveParams SaveParams = (PBitmapCodecSaveParams)(0x0));
__classmethod System::Types::TPointF __fastcall GetImageSize(const System::UnicodeString AFileName);
__classmethod bool __fastcall IsValid(System::Classes::TStream* const AStream);
bool __fastcall LoadThumbnailFromFile(const System::UnicodeString AFileName, const float AFitWidth, const float AFitHeight, const bool UseEmbedded, Fmx::Surfaces::TBitmapSurface* const Bitmap);
};
The class Fmx::Surfaces::TBitmapSurface has no trace of documentation, but the IDE provided me with available functions. I figured the Pixels[x][y] array is used to read/write the pixels.
After the class has been registered, you can read the new image type as usual with TBitmap->LoadFromFile("");
Enjoy!
PS. Those who voted to close this, please put in a comment to why? How can we improve if we don't know what mistakes we do?
You need to derive a new class from TCustomBitmapCodec and implement the virtual LoadFrom...() and SaveTo...() methods, and then register the class at app startup using TBitmapCodecManager::RegisterBitmapCodecClass().
We know that we call pthread like this:
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void* arg);
Hi guys, i want to know why the return type of third parameter is void*? why not void?
Because there is no way for a start function to know what kind of data a developer wants to return from the function they use a void* that can point to any type. It is up to the developer of the start function to then cast the void* to appropriate type he actually returned before using whatever the void* points to. So now the start function can return a pointer that may in actually point to anything. If the start function is declared to return void, it means this function returns nothing, then what if the developer wants the start function to return a int, a struct? For example:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
struct test {
char str[32];
int x;
};
void *func(void*) {
struct test *eg = (struct test *)malloc(sizeof(struct test));
strcpy(eg->str,"hello world");
eg->x = 42;
pthread_exit(eg);
}
int main (void) {
pthread_t id;
struct test *resp;
pthread_create(&id, NULL, func, NULL);
pthread_join(id,(void**)&resp);
printf("%s %d\n",resp->str,resp->x);
free(resp);
return 0;
}
More details on this post: What does void* mean and how to use it?
Delphi syntax:
procedure Move(const Source; var Dest; Count: Integer);
C++ syntax:
extern PACKAGE void __fastcall Move(const void *Source, void *Dest, int Count);
I have used Function Move in Delphi long time ago,
recently I want to call it in C++ Builder 6,
I wrote it as the same as I did in Delphi,
the error appearance --> "Expression Syntax".
Dose anyone know how to call it?
or there is other function works similar to it?
BYTE src[] = "Source Data";
BYTE dst[11];
Move(src, dst, sizeof(dst));
It is better to use memmove in C++:
memmove(dst, src, sizeof(dst));