这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 斑竹急各位使用 Vxworks&Zinc大狭———求助!!!

共1条 1/1 1 跳转至

斑竹急各位使用 Vxworks&Zinc大狭———求助!!!

菜鸟
2006-04-14 06:41:23     打赏

版主及各位“高人”小弟最近用Zinc做一个界面,其中主界面能在目标机上正常显示,而当按主界面的一个按钮按理应该弹出一个对话框,结果出现一个全空无颜色的界面(没有任何控件,这也比应该出现的对话框和主界面大得多,而应该出现的对话框是有颜色的,有控件的)。为此我又简化主界面和当按主界面的一个按钮按理应该弹出一个对话框的控件,主界面只有一个按钮,设为浅绿色,和当按主界面的一个按钮按理应该弹出一个对话框的控件是几个字。属性不应该有问题,因为主界面的控件及颜色都能正常显示,为什么当按主界面的一个按钮出现一个全空无颜色的大界面(而编译下载都正确没有提示错误)????原因可能是代码添加的有问题请各位指点,小弟非常感激 !!!
以下是简化界面控件生成的代码及添加的代码(添加的代码在2个add之间 只在MainWind..CPP,MainWind..HPP两个文件加代码,其它文件保持原样)
我的email: fewwang@126.com
文件1. can.cpp
// Main program file generated by Zinc Designer.

#include "MainWind.hpp"
#include "gps.hpp"

#include "can.inc"

int ZafApplication::Main(void)
{
// Ensure main() is linked properly.
LinkMain();

// Establish access to external objects and data.
ZafStorage *storage = new ZafStorage(ZAF_ITEXT("C:/homedir/can7.znc"), ZAF_FILE_READ);
if (storage->Error())
{
errorSystem->ReportError(ZAF_NULLP(ZafWindowObject),
ZAF_ITEXT("Error"), ZAF_DIALOG_OK,
ZAF_ITEXT("can7.znc could not be found."));
delete storage;
return (-1);
}

objectPersistence = new UserPersist(storage);

// Display initial windows.
windowManager->Add(new MainWind(ZAF_ITEXT("MainWind"), *objectPersistence));


// Get the user input.
Control();

delete objectPersistence;
objectPersistence = ZAF_NULLP(ZafObjectPersistence);
delete storage;

// Return success.
return (0);
}

文件2. can.hpp
#if !defined(INC_can_HPP)
#define INC_can_HPP

#include <zinc/z_win.hpp>

class UserPersist : public ZafObjectPersistence
{
public:
UserPersist(ZafFileSystem *fileSystem) :
ZafObjectPersistence(fileSystem, dataTable, objectTable, userFunctionTable, compareFunctionTable, userObjectTable, drawHookTable, listenerCtorTable) { }

static DataConstructor ZAF_FARDATA dataTable[];
static ObjectConstructor ZAF_FARDATA objectTable[];
static UserFunction ZAF_FARDATA drawHookTable[];
static CListener ZAF_FARDATA listenerCtorTable[];
static UserFunction ZAF_FARDATA userFunctionTable[];
static CompareFunction ZAF_FARDATA compareFunctionTable[];
static UserObject ZAF_FARDATA userObjectTable[];
};

#endif // INC_can_HPP

文件3. MainWind.cpp
// CPP file for class MainWind

#include "MainWind.hpp"
//**************************add**********************************//
MainWind *pMainWind;
const ZafEventType B_1 = 10001;
://**************************add**********************************//
ZafClassNameChar ZAF_FARDATA MainWind::className[] = ZAF_ITEXT("MainWind");

MainWind::MainWind(const ZafIChar *name, ZafObjectPersistence &persist) :
ZafWindow(name, persist)
{
**************************add**********************************//
pMainWind=this;
GetPtr();
**************************add**********************************//
}

MainWind::~MainWind()
{
//**************************add**********************************//
delete pGPS;
pMainWind=NULL;
//**************************add**********************************//
}

ZafElement *MainWind::Read(const ZafIChar *name, ZafObjectPersistence &persist)
{
return (new MainWind(name, persist));
}

bool MainWind::IsA(ZafClassName compareName) const
{
return (!strcmp(compareName, className) ? true : ZafWindow::IsA(compareName));
}

ZafEventType MainWind::ClassDraw(const ZafEventStruct &event, ZafEventType ccode)
{
return (ZafWindow::ClassDraw(event, ccode));
}

ZafEventType MainWind::Event(const ZafEventStruct &event)
{
ZafEventType ccode = LogicalEvent(event);
switch(ccode)
{
//**************************add**********************************//
case B_1:
{
pGPS->SetOwner(this);
WindowManager()->Add(pGPS);

}
break;
//**************************add**********************************//
default:
ccode = ZafWindow::Event(event);
}
return (ccode);
}
//**************************add**********************************//
bool MainWind::GetPtr(void)
{
pGPS = new GPS(ZAF_ITEXT("pGPS"),*zafApplication->ObjectPersistence());
}
//**************************add**********************************//


文件4. MainWind.hpp

// HPP file for class MainWind

#if !defined(MainWind_HPP)
# define MainWind_HPP

//**************************add**********************************//
#include <zinc/zaf.hpp#include "GPS.hpp"
//**************************add**********************************//
class MainWind : public ZafWindow
{
public:
MainWind(const ZafIChar *name, ZafObjectPersistence &persist);
~MainWind();

ZafEventType ClassDraw(const ZafEventStruct &event, ZafEventType ccode);

ZafEventType Event(const ZafEventStruct &event);

static ZafElement *Read(const ZafIChar *name, ZafObjectPersistence &persist);

// --- Class identification ---
static ZafClassNameChar ZAF_FARDATA className[];
virtual ZafClassName ClassName(void) const { return (className); }
virtual bool IsA(ZafClassName compareName) const;
//**************************add**********************************//
public:
GPS *GetGPS(){return pGPS;}
bool GetPtr(void);
GPS *pGPS;
//**************************add**********************************//
};
#endif // MainWind_HPP

文件5. GPS.cpp

// CPP file for class GPS

#include "gps.hpp"

ZafClassNameChar ZAF_FARDATA GPS::className[] = ZAF_ITEXT("GPS");

GPS::GPS(const ZafIChar *name, ZafObjectPersistence &persist) :
ZafDialogWindow(name, persist)
{
}

GPS::~GPS()
{
}

ZafElement *GPS::Read(const ZafIChar *name, ZafObjectPersistence &persist)
{
return (new GPS(name, persist));
}

bool GPS::IsA(ZafClassName compareName) const
{
return (!strcmp(compareName, className) ? true : ZafDialogWindow::IsA(compareName));
}

ZafEventType GPS::ClassDraw(const ZafEventStruct &event, ZafEventType ccode)
{
return (ZafDialogWindow::ClassDraw(event, ccode));
}

ZafEventType GPS::Event(const ZafEventStruct &event)
{
ZafEventType ccode = LogicalEvent(event);
switch(ccode)
{
default:
ccode = ZafDialogWindow::Event(event);
}
return (ccode);
}

文件6. GPS.hpp

// HPP file for class GPS

#if !defined(gps_HPP)
# define gps_HPP

#include <zinc/zaf.hpp>

class GPS : public ZafDialogWindow
{
public:
GPS(const ZafIChar *name, ZafObjectPersistence &persist);
~GPS();

ZafEventType ClassDraw(const ZafEventStruct &event, ZafEventType ccode);

ZafEventType Event(const ZafEventStruct &event);

static ZafElement *Read(const ZafIChar *name, ZafObjectPersistence &persist);

// --- Class identification ---
static ZafClassNameChar ZAF_FARDATA className[];
virtual ZafClassName ClassName(void) const { return (className); }
virtual bool IsA(ZafClassName compareName) const;
};
#endif // gps_HPP


文件7. V_APP.CPP
// Zinc Application Framework - V_APP.CPP
// Copyright (c) 1990-1998 Zinc Software, Inc.
// Copyright (c) 1999-2000 Wind River Systems, Inc.

#include <zinc/z_app.hpp>
#include <zinc/z_error.hpp> // For Beep().

#include <taskLib.h>

// ----- main ---------------------------------------------------------------

int ZafVxWorksMain(void)
{
// Call the application program.
ZafApplication application(0, 0);
if (application.Error() == ZAF_ERROR_CONSTRUCTOR)
{
// The ZafApplication object was not fully constructed.
ZafErrorStub::Beep();
return (1);
}
else
return (application.Main());
}

extern "C"
{
int can()
{
if (taskSpawn("ZAF_CAN", 90, VX_FP_TASK, ZAF_VXW_STACK_SIZE,
(FUNCPTR)ZafVxWorksMain, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) != ERROR)
return (0);
else
return (-1);
}
}






关键词: 斑竹     各位     使用     Vxworks     大狭     求助     一个    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]