Public feed #888584

Anonymous

public cpp v1 · immutable
Raw Edit
·published 2008-02-02 07:08 UTC
rendered paste body
$ windres -i a.rc -o a.o$ g++ -c test.cpp$ g++ test.o a.o -o a.exe -lwinmm -o a.exe$ ./a.exe=====================================================================================================================a.rc=====================================================================================================================#include <windows.h>CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "a.exe.manifest"=====================================================================================================================test.cpp=====================================================================================================================#include <iostream>#include <windows.h>static int button_id = 156; // choose any positive integerBOOL WINAPI myProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){	if (message == WM_CLOSE)		PostQuitMessage(0);	//check if button was clicked	if(message == WM_COMMAND && LOWORD(wParam) == button_id)	{		mciSendString("open song.mp3 type mpegvideo alias myFile",			      NULL, 0, 0			);		mciSendString("play myFile", NULL, 0, 0);			      //MessageBox(hwnd, "button has been clicked", "Message Title", 0);	}	return false;}int main(int argc, char *argv[]){	MSG msg;	HWND myDialog = CreateWindowEx(		0, WC_DIALOG, "My Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE,		400, 100, 200, 200, NULL, NULL, NULL, NULL		);	// create button	CreateWindowEx(		0, "BUTTON", "Click me", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,		50, 50, 100, 25, myDialog, (HMENU)button_id, NULL, NULL		);   	SetWindowLong(myDialog, DWL_DLGPROC, (long)myProc);	while (GetMessage(&msg, NULL, 0, 0))	{		TranslateMessage(&msg);		DispatchMessage(&msg);	}	mciSendString("close myFile", NULL, 0, 0);	return 0;}=====================================================================================================================a.exe.manifest=====================================================================================================================<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly 	xmlns="urn:schemas-microsoft-com:asm.v1" 	manifestVersion="1.0"><assemblyIdentity     version="1.0.0.0"     processorArchitecture="X86"     name="a.exe"     type="win32"/><description>Test Application</description><dependency>     <dependentAssembly>         <assemblyIdentity             type="win32"             name="Microsoft.Windows.Common-Controls"             version="6.0.0.0"             processorArchitecture="X86"             publicKeyToken="6595b64144ccf1df"             language="*"/>     </dependentAssembly></dependency></assembly>