在这里,我将记事本和记算器都放到了自己所做的一个应用程序中,感觉还不错!其实,程序非常简单,只有几句话罢了!
程序的界面为:
如果在自己的程序中需要用到这些功能,可不要忘记这个功能哟!因为,大家可以把Word、Excel甚至是LabWindows/CVI都放到自己的一个一个窗口环境中去,是不是很有意思?!
代码为:
#include "windows.h"
#include "shellapi.h"
#include
#include
#include "window.h"
#include "shellapi.h"
#include
#include
#include "window.h"
static int handle;
static int panelHandle;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /*
out of memory */
if ((panelHandle = LoadPanel (0, "window.uir",
PANEL)) < 0)
return -1;
GetPanelAttribute (panelHandle,
ATTR_SYSTEM_WINDOW_HANDLE, &handle);
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
{
}
int CVICALLBACK calc (int panel, int control, int event,
void *callbackData, int
eventData1, int eventData2)
{
HWND hwnd;
switch (event)
{
case EVENT_COMMIT:
ShellExecute((HWND)handle,
"open", "calc.exe", NULL, NULL, SW_NORMAL);
hwnd =
FindWindow(NULL, "计算器");
SetParent(hwnd,
(HWND)handle);
break;
}
return 0;
}
{
}
int CVICALLBACK notepad (int panel, int control, int
event,
void *callbackData, int
eventData1, int eventData2)
{
HWND hwnd;
switch (event)
{
case EVENT_COMMIT:
ShellExecute((HWND)handle,
"open", "notepad.exe", NULL, NULL, SW_NORMAL);
hwnd =
FindWindow(NULL, "无标题 - 记事本");
SetParent(hwnd,
(HWND)handle);
break;
}
return 0;
}
{
}
int CVICALLBACK QuitCallback (int panel, int control, int
event,
void *callbackData, int
eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface
(0);
break;
}
return 0;
}
{
}
前一篇:认识虚拟仪器