Article View: borland.public.cppbuilder.nativeapi
Article #3393Opening a file from WM_COPYMESSAGE
From: sez
Date: Mon, 19 Jun 2006 00:48
Date: Mon, 19 Jun 2006 00:48
65 lines
2637 bytes
2637 bytes
I have coded this but what is wrong?
//-------main.cpp--------------------------------------------------------------
void __fastcall TMainForm::WmCopyData(TWMCopyData &Msg)
{
ShowMessage("test"); // fails
}
//-------main.h--------------------------------------------------------------
private:
void __fastcall WMDropFiles(TWMDropFiles &Msg); // DragDrop
void __fastcall WmCopyData(TWMCopyData &Msg);
public:
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_COPYDATA, TWMCopyData, WmCopyData)
MESSAGE_HANDLER(WM_DROPFILES,TWMDropFiles,WMDropFiles)
END_MESSAGE_MAP(TForm)
//-------App.cpp--------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
USEFORM("main.cpp", MainForm);
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR cmdLine, int)
{
// My
HANDLE hSemaphore = ::CreateSemaphore(NULL,1,1, "App.SEMAPHORE");
if(hSemaphore && WaitForSingleObject(hSemaphore, 0) != WAIT_OBJECT_0) {
CloseHandle(hSemaphore);
HWND hWnd = ::FindWindow("TApplication", "App 1.0");
if (::IsIconic(hWnd)) // If it is minimized
{
::ShowWindow(hWnd, SW_SHOWDEFAULT); // Show it
}
::SetForegroundWindow(hWnd); // Bring it to the foreground
if (strlen(cmdLine) != 0) {
COPYDATASTRUCT cds;
cds.cbData = strlen(cmdLine) + 1;
cds.lpData = cmdLine;
SendMessage(hWnd, WM_COPYDATA, 0, (LPARAM)&cds);
}
return 0;
}
Application->Initialize();
Application->Title = "App 1.0";
Application->CreateForm(__classid(TMainForm), &MainForm);
Application->Run();
ReleaseSemaphore(hSemaphore,1,NULL);
CloseHandle(hSemaphore);
return 0;
}
Technical Details
Message-ID:
<4495f47e@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9166deaa46235045,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "sez" <www@sezginserin.com> From: "sez" <www@sezginserin.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Opening a file from WM_COPYMESSAGE Date: Mon, 19 Jun 2006 03:48:51 +0300 Lines: 67 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 NNTP-Posting-Host: 85.97.22.172 Message-ID: <4495f47e@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1150678142 85.97.22.172 (18 Jun 2006 17:49:02 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail