|
Hello everyone,
I'm working on a project that involves texture mapping. The idea is that we want to see how the inside of an object looks like. So we have to make a crossection, the system already creates a bitmap of how the object would look like in the inside, but I need to texture map that bitmap on the crossection.
The problem is that the bitmap created still has some black borders and pieces in it. I want those colors to be transparant so that I can still see the rest of my object in 3D.
What I'm thinking of is the following. First we isolate the object inside the bitmap, take a rectangle region out of it and make the black color transparant. Now we've got a rectangle with our object inside of it without any black borders. Now we need to texture map that rectangle onto our object in 3D space. We need to calculate the a rectangle around our object in 3D space to texture map our bitmap to.
Can someone please help me.
I already found some good code for making the black color transparant.
Thanks in advance
zeno81
|
|
|
|
|
Hi There,
I continually find that I start implementing stuff then change my mind or handle some VC event and then decide that I actually what to handle anothe event and so end up with a whole pile of vc++ generated kludge. SO is there a tool that I can run so that I run the app run all the buttons and change all the parameters that I want and then after the app exists it wil colour code it. e.g. red code is not to be touched and blue code is code that hasn't been referenced or is safe to delete. E.g. do I really have to delete the ON_COMMAND_UI the afx mesage On command in the .h and the actual function in the C++ file if I change my mind for one menu item. Am imissing something is there a better way.
Do most people have a huge view class which has all the events they want to handle or do they put that in another class. Do most people actually keep the data not in the document but in the view in doc/view arch so they dont have to prefix all their data with GetDocument()
It seems to me that when changing menu ordering around or even changing a control on a dialog app that it requires a lot of work. How does everyone else do this? Does this mean that I need to design more carefully? Do other people have little test beds? I was thinking of having say a dialog app with buttons for each new test feature I want to add and then adding a class implementing that behavior so I can have little modules of the behavior that I want which I can then add them to the main module. Also do people here use CVS or do they actually use source safe which even MS does not recommened. If people use CVS then how do they cope with e.g. converting a class to a dll and cvs add and removing the correct folders and MS VC++ generated stuff? Why can I use dc->SetBkColor to change the background of most controls but I have to use OnEraseBkgrnd to change the colour of a view in a MDI/SDI app. (Why can't i Use SetBkCOlor for everything) Is having controls in a mdi view a bad idea since you have to manually calculate the offsets rather than a diaog app when you can just plonk them on? Do most people here actually know 5/6 languages inside out or do they only really know 1 or 2 really well. e.g. would people say they know MFC inside out or just subsets of it.
|
|
|
|
|
Lots of questions;
1. No, there is no tool with VC++, you'd need to use some kind of code coverage tool to achieve that, and it wouldn't colour-code.
2. ClassWizard will delete some stuff, if you let it.
3. Depends. Can't speak for everyone else, but I keep document data in the document. The overhead involved in typing disappears at run-time, and the overhead of an extra dereference is worth the encapsulation benefits.
You aren't really an O-O person, are you?
4. If your UI requires a lot of changes, you haven't spent enough time on the design.
5. Yes, lots of small testbed applications. Otherwise how can you be sure it's not an issue with side-effects from something else.
6. SourceSafe works fine, if you accept the fact that it doesn't handle branching in a useful way (i.e. 1.1.2 and 1.2 "in parallel")
7. Simple. No regeneratable files go into the repository, so no NCB, CLW, APS etc, and no MIDL generated files either. Proper rules, and enforcement.
8. Because it doesn't work that way. OnEraseBkgrnd does "what it says on the tin". You aren't using SetBkColor to change the background of a control, mostly. If you do your own drawing you will, and if you handle WM_CTLCOLORxxxx you can but that's because of a design feature (callback) rather than "the way it's done everywhere else".
9. Control placement is your responsibility for anything other than a dialog. If you want to use a dialog template to set up controls in a simple view, I don't see anyone stopping you. You could use ideas and code from sites like this one.
10. Can't speak for everyone else, but I know two or three well, and the
environments I work in quite well too. I don't know MFC inside out, but I know it well enough to navigate the documentation and source code.
'Nuff said.
Steve S
Please do not feed the troll - it bites back
|
|
|
|
|
i have defined a class of "CChildFrame" ,its base class is CMDICHILDWND,
then i define "CChildFrame*p_ADD" in "MainFrm.h",
when i "p_ADD=new CChildFrame();" in "MainFrm.cpp".when run ,point out:
1 error o warning.
but after i "//p_ADD=new CChildFrame();" ,all ok?
please help me
|
|
|
|
|
what error does the compiler really give you ?
TOXCCT >>> GEII power
|
|
|
|
|
vividtang wrote:
then i define "CChildFrame*p_ADD" in "MainFrm.h",
At this point, the CChildFrame-class is known to the compiler?
You either need to have the ChildFrame.h-file #include -ed in MainFrm.h , or you can, as you ar only declaring a pointer to the class, not an instance itself, write
class CChildFrame; just below all includes, but before the class starts. This is called 'forward-declaration' and is the C++ way of telling the compiler: "Shut up, you will know that class when you really need it!".
But you have to keep that promise: When the compiler is asked to construct the instance of CChildFrame , in the new() statement, the class must be fully known. To achieve this, just write
#include "ChildFrame.h" in MainFrame.cpp at the top. Best to put it after all other #include s.
This should then compile cleanly.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
thank you jhwurmbach, i have writen in MainFrm.h and in MainFrm.cpp #include
cchildframe.h,but i didn't work, i have spend for a year for this error.
|
|
|
|
|
vividtang wrote:
but i didn't work
What does that mean? Please post the exact error messages so I can really start to help you.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach ,thank you again.please help me
below it is my "MainFrm.h"
#include "TheChildFrame.h"
#if !defined(AFX_MAINFRM_H__72AAD2C8_6374_49B1_907D_7CA96509F1F8__INCLUDED_)
#define AFX_MAINFRM_H__72AAD2C8_6374_49B1_907D_7CA96509F1F8__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CMDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
CMainFrame();
// Attributes
public:
CTheChildFrame *m_pAdd,*m_pChange; // 指向三个功能窗口
BOOL m_bLogin; // 登录状态
BOOL m_bItemAdd,m_bItemChange; // 相应的菜单项及工具栏按钮是否可用
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnUpdateSystemConnect(CCmdUI* pCmdUI);
afx_msg void OnUpdateSystemDisconnect(CCmdUI* pCmdUI);
afx_msg void OnUpdateManageAdd(CCmdUI* pCmdUI);
afx_msg void OnSystemConnect();
afx_msg void OnSystemDisconnect();
afx_msg void OnDestroy();
afx_msg void OnManageAdd();
afx_msg void OnUpdateManagerChange(CCmdUI* pCmdUI);
afx_msg void OnManagerChange();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__72AAD2C8_6374_49B1_907D_7CA96509F1F8__INCLUDED_)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
below it is my "MainFrm.cpp"
#include "stdafx.h"
#include "Personnel3.h"
#include "LoginDlg.h"
#include "AddView.h"
#include "ChangeView.h"
#include "MainFrm.h"
//#include "TheChildFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//include "TheChildFrame.h"
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
extern CDatabase db;
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_UPDATE_COMMAND_UI(ID_SYSTEM_CONNECT, OnUpdateSystemConnect)
ON_UPDATE_COMMAND_UI(ID_SYSTEM_DISCONNECT, OnUpdateSystemDisconnect)
ON_UPDATE_COMMAND_UI(ID_MANAGE_ADD, OnUpdateManageAdd)
ON_COMMAND(ID_SYSTEM_CONNECT, OnSystemConnect)
ON_COMMAND(ID_SYSTEM_DISCONNECT, OnSystemDisconnect)
ON_WM_DESTROY()
ON_COMMAND(ID_MANAGE_ADD, OnManageAdd)
ON_UPDATE_COMMAND_UI(ID_MANAGER_CHANGE, OnUpdateManagerChange)
ON_COMMAND(ID_MANAGER_CHANGE, OnManagerChange)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR,
//ID_INDICATOR_LOGIN,
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
m_bLogin=FALSE; // 缺省未登录
m_bItemAdd=FALSE; // "增加新员工"功能缺省为不可用
m_bItemChange=FALSE; // "人事变动"功能缺省为不可用
//m_bItemSearch=FALSE; // "查询修改"功能缺省为不可用
m_pAdd=m_pChange=NULL;
// 初始化为空
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnUpdateSystemConnect(CCmdUI* pCmdUI)
{ pCmdUI->Enable(!m_bLogin);
}
void CMainFrame::OnUpdateSystemDisconnect(CCmdUI* pCmdUI)
{ pCmdUI->Enable(m_bLogin);
}
void CMainFrame::OnUpdateManageAdd(CCmdUI* pCmdUI)
{ pCmdUI->Enable(m_bItemAdd);
}
void CMainFrame::OnUpdateManagerChange(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_bItemChange);
}
void CMainFrame::OnSystemConnect()
{
CLoginDlg dlg;
if(dlg.DoModal()==IDOK)
{
m_bLogin=TRUE; // 已登录
m_bItemAdd=TRUE; // 开放"增加新员工"功能
m_bItemChange=TRUE; // 开放"人事变动"功能
// m_bItemSearch=TRUE; // 开放"查询修改"功能
}
}
void CMainFrame::OnSystemDisconnect()
{
db.Close(); // 关闭数据库
// 关闭所有子框架窗口
if(m_pAdd) m_pAdd->DestroyWindow();
if(m_pChange) m_pChange->DestroyWindow();
//if(m_pSearch) m_pSearch->DestroyWindow();
m_bLogin=FALSE; // 未登录
m_bItemAdd=FALSE; // 禁止"增加新员工"功能
m_bItemChange=FALSE; // 禁止"人事变动"功能
//m_bItemSearch=FALSE; // 禁止"查询修改"功能
// 改变状态栏
//m_wndStatusBar.SetPaneText(1, "尚未登录数据库!请按F2登录");
}
void CMainFrame::OnDestroy()
{
CMDIFrameWnd::OnDestroy();
if(db.IsOpen()) db.Close();
}
void CMainFrame::OnManageAdd()
{
// 创建新子框架和视
m_pAdd=new CTheChildFrame(); /*
CCreateContext context;
context.m_pNewViewClass=RUNTIME_CLASS(CAddView);
if(!m_pAdd->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_PREFIXTITLE ,this, &context )) return;
m_pAdd->InitialUpdateFrame(NULL,TRUE);
m_bItemAdd=FALSE; // 禁止"增加新员工"功能*/
}
void CMainFrame::OnManagerChange()
{
// 创建新子框架和视
// m_pChange = new MainFrmame();
/* CCreateContext context;
context.m_pNewViewClass=RUNTIME_CLASS(CChangeView);
if(!m_pChange->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_PREFIXTITLE ,this, &context )) return;
m_pChange->InitialUpdateFrame(NULL,TRUE);
m_bItemChange=FALSE; // 禁止"人事变动"功能 */
}
below it is "AddView.cpp"
#include "stdafx.h"
#include "Personnel3.h"
#include "AddView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAddView
extern CDatabase db;
IMPLEMENT_DYNCREATE(CAddView, CFormView)
CAddView::CAddView()
: CFormView(CAddView::IDD)
{
//{{AFX_DATA_INIT(CAddView)
m_strDepartment = _T("");
m_strEdulevel = _T("");
m_strJob = _T("");
m_strBirthday = _T("");
m_strEmail = _T("");
m_strID = _T("");
m_strMemo = _T("");
m_strName = _T("");
m_strPasswd = _T("");
m_strSpecialty = _T("");
m_strAddress = _T("");
m_strTel = _T("");
//}}AFX_DATA_INIT
}
CAddView::~CAddView()
{
}
void CAddView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAddView)
DDX_Control(pDX, IDC_ADD_CMB_JOB, m_cJob);
DDX_Control(pDX, IDC_ADD_CMB_EDULEVEL, m_cEdulevel);
DDX_Control(pDX, IDC_ADD_CMB_DEPARTMENT, m_cDepartment);
DDX_CBString(pDX, IDC_ADD_CMB_DEPARTMENT, m_strDepartment);
DDX_CBString(pDX, IDC_ADD_CMB_EDULEVEL, m_strEdulevel);
DDX_CBString(pDX, IDC_ADD_CMB_JOB, m_strJob);
DDX_Text(pDX, IDC_ADD_EDT_BIRTHDAY, m_strBirthday);
DDX_Text(pDX, IDC_ADD_EDT_EMAIL, m_strEmail);
DDX_Text(pDX, IDC_ADD_EDT_ID, m_strID);
DDX_Text(pDX, IDC_ADD_EDT_MEMO, m_strMemo);
DDX_Text(pDX, IDC_ADD_EDT_NAME, m_strName);
DDX_Text(pDX, IDC_ADD_EDT_PASSWD, m_strPasswd);
DDX_Text(pDX, IDC_ADD_EDT_SPECIALTY, m_strSpecialty);
DDX_Text(pDX, IDC_ADD_EDT_ADDRESS, m_strAddress);
DDX_Text(pDX, IDC_ADD_EDT_TEL, m_strTel);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAddView, CFormView)
//{{AFX_MSG_MAP(CAddView)
ON_BN_CLICKED(IDC_ADD_BTN_ADD, OnAddBtnAdd)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAddView diagnostics
#ifdef _DEBUG
void CAddView::AssertValid() const
{
CFormView::AssertValid();
}
void CAddView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CAddView message handlers
void CAddView::Init()
{
// 清空成员变量
m_strID = _T("");
m_strPasswd = _T("");
m_strName = _T("");
m_strBirthday = _T("");
m_strDepartment = _T("");
m_cDepartment.SetCurSel(-1);
m_strJob = _T("");
m_cJob.SetCurSel(-1);
m_strEdulevel = _T("");
m_cEdulevel.SetCurSel(-1);
m_strSpecialty = _T("");
m_strAddress = _T("");
m_strTel = _T("");
m_strEmail = _T("");
m_strMemo = _T("");
// 生成员工号
CString str;
int counter; // 用于计数
CRecordset rs(&db); // 数据集
rs.Open(CRecordset::forwardOnly,
"select COUNTER_VALUE from COUNTER where ID='P'");
rs.GetFieldValue("COUNTER_VALUE", str);
sscanf(str, "%d", &counter); // 获取计数值
rs.Close();
str.Format("P%05d", counter); // 产生标准格式的编号
m_strID=str; // 自动产生员工号
m_strPasswd=str; // 默认密码为员工号
// 设置缺省性别为男
((CButton*)GetDlgItem(IDC_ADD_RADIO_MALE))->SetCheck(TRUE);
UpdateData(FALSE); // 更新界面数据
}
void CAddView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit(FALSE);
GetParentFrame()->SetWindowText("增加新员工"); // 设置标题
CRecordset rs(&db); // 数据集
CString str;
// 设置部门下拉框所取的值为DEPARTMENT表中的值
rs.Open(CRecordset::forwardOnly, "select NAME from DEPARTMENT");
while(!rs.IsEOF())
{
rs.GetFieldValue("NAME", str);
m_cDepartment.AddString(str);
rs.MoveNext();
}
rs.Close();
// 设置职务下拉框所取的值为JOB表中的值
rs.Open(CRecordset::forwardOnly, "select DESCRIPTION from JOB");
while(!rs.IsEOF())
{
rs.GetFieldValue("DESCRIPTION", str);
m_cJob.AddString(str);
rs.MoveNext();
}
rs.Close();
// 设置受教育水平下拉框所取的值为EDU_LEVEL表中的值
rs.Open(CRecordset::forwardOnly, "select DESCRIPTION from EDU_LEVEL");
while(!rs.IsEOF())
{
rs.GetFieldValue("DESCRIPTION", str);
m_cEdulevel.AddString(str);
rs.MoveNext();
}
rs.Close();
Init(); // 调用初始化函数
}
void CAddView::OnAddBtnAdd()
{ CString str,strSQL;
int counter; // 用于计数
CRecordset rs(&db); // 数据集
UpdateData(); // 更新数据
if(m_strName.IsEmpty()) // 姓名为空则返回
{
AfxMessageBox("姓名不能为空!");
return;
}
// 累加员工编号计数器
rs.Open(CRecordset::forwardOnly,"select COUNTER_VALUE from COUNTER where ID='P'");
rs.GetFieldValue("COUNTER_VALUE", str);
sscanf(str, "%d", &counter); // 获取计数值
rs.Close(); // 关闭数据集
counter++; // 计数值加1
str.Format("%d", counter); // 转换为字符串
strSQL="update COUNTER set COUNTER_VALUE=" + str + " where ID='P'"; // 设置SQL语句
db.ExecuteSQL(strSQL); // 执行
// 增加员工个人信息记录
CString strPasswd,strSex,strDepID,strJobID,strEduID;
// 判断生日是否为空
if(m_strBirthday.IsEmpty()) m_strBirthday="1900-1-1"; // 缺省值
// 加密密码
strPasswd=m_strPasswd;
// 判断性别
if(((CButton*)GetDlgItem(IDC_ADD_RADIO_MALE))->GetCheck()) strSex="M";
else strSex="F";
// 得到部门ID
rs.Open(CRecordset::forwardOnly,
"select ID from DEPARTMENT where NAME='" + m_strDepartment +"'");
rs.GetFieldValue("ID", strDepID);
rs.Close();
// 得到职务代码
rs.Open(CRecordset::forwardOnly,
"select CODE from JOB where DESCRIPTION='" + m_strJob +"'");
rs.GetFieldValue("CODE", strJobID);
rs.Close();
// 得到受教育水平代码
rs.Open(CRecordset::forwardOnly,
"select CODE from EDU_LEVEL where DESCRIPTION='" + m_strEdulevel +"'");
rs.GetFieldValue("CODE", strEduID);
rs.Close();
// 写SQL语句
strSQL="insert into PERSON(ID,PASSWD,NAME,SEX,\
BIRTHDAY,DEPARTMENT,JOB,EDU_LEVEL,SPECIALTY,\
ADDRESS,TEL,EMAIL,REMARK) \
values('"
+ m_strID + "','" // ID
+ strPasswd + "','" // PASSWD
+ m_strName + "','" // NAME
+ strSex + "','" // SEX
+ m_strBirthday + "','" // BIRTHDAY
+ strDepID + "','" // DEPARTMENT
+ strJobID + "','" // JOB
+ strEduID + "','" // EDU_LEVEL
+ m_strSpecialty + "','" // SPECIALTY
+ m_strAddress + "','" // ADDRESS
+ m_strTel + "','" // TEL
+ m_strEmail + "','" // EMAIL
+ m_strMemo + "')"; // REMARK
db.ExecuteSQL(strSQL); // 执行
// 获取人事变动记录号并累加
rs.Open(CRecordset::forwardOnly,
"select COUNTER_VALUE from COUNTER where ID='C'");
rs.GetFieldValue("COUNTER_VALUE", str);
sscanf(str, "%d", &counter); // 获取计数值
rs.Close(); // 关闭数据集
counter++; //计数值加1
str.Format("%d", counter); // 转换为字符串
strSQL="update COUNTER set COUNTER_VALUE=" + str + " where ID='C'"; // 设置SQL语句
db.ExecuteSQL(strSQL); // 执行
// 追加人事变动记录
str.Format("%d",counter); // 计数值转换为字符串
CTime time=CTime::GetCurrentTime();
CString strNow=time.Format("%Y-%m-%d %H:%M:%S");
// 写SQL语句
strSQL="insert into PERSONNEL(ID,PERSON,CHANGE,\
RECORD_TIME,DESCRIPTION)\
values("
+ str + ",'" // ID
+ m_strID + "','" // PERSON
+ "0" + "','" // CHANGE - 加入公司代码
+ strNow + "','" // RECORD_TIME
+ "加入公司')"; // DESCRIPTION
db.ExecuteSQL(strSQL);
// 重新初始化窗口
Init();
}
void CAddView::OnDestroy()
{
CFormView::OnDestroy();
((CMainFrame*)AfxGetMainWnd())->m_bItemAdd=TRUE; // 开放"增加新员工"功能
((CMainFrame*)AfxGetMainWnd())->m_pAdd=NULL; // 清空窗口指针
}
|
|
|
|
|
jhwurmbach ,thank you again.please help me,only write m_pAdd=new TheChildFrame(),1 error o warning,
below it is my "MainFrm.h" in short
#include "TheChildFrame.h"
class CMainFrame : public CMDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
CMainFrame();
// Attributes
public:
CTheChildFrame *m_pAdd,*m_pChange; // BOOL m_bLogin;
BOOL m_bItemAdd,m_bItemChange;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
below it is my "MainFrm.cpp"
#include "stdafx.h"
#include "Personnel3.h"
#include "LoginDlg.h"
#include "AddView.h"
#include "ChangeView.h"
#include "MainFrm.h"
//include "TheChildFrame.h"
extern CDatabase db;
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_UPDATE_COMMAND_UI(ID_SYSTEM_CONNECT, OnUpdateSystemConnect)
ON_UPDATE_COMMAND_UI(ID_SYSTEM_DISCONNECT, OnUpdateSystemDisconnect)
ON_UPDATE_COMMAND_UI(ID_MANAGE_ADD, OnUpdateManageAdd)
ON_COMMAND(ID_SYSTEM_CONNECT, OnSystemConnect)
ON_COMMAND(ID_SYSTEM_DISCONNECT, OnSystemDisconnect)
ON_WM_DESTROY()
ON_COMMAND(ID_MANAGE_ADD, OnManageAdd)
ON_UPDATE_COMMAND_UI(ID_MANAGER_CHANGE, OnUpdateManagerChange)
ON_COMMAND(ID_MANAGER_CHANGE, OnManagerChange)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
m_bLogin=FALSE; m_bItemAdd=FALSE; m_bItemChange=FALSE; m_bItemSearch=FALSE; m_pAdd=m_pChange=NULL;
}
CMainFrame::~CMainFrame()
{
}
void CMainFrame::OnUpdateSystemConnect(CCmdUI* pCmdUI)
{ pCmdUI->Enable(!m_bLogin);
}
void CMainFrame::OnUpdateSystemDisconnect(CCmdUI* pCmdUI)
{ pCmdUI->Enable(m_bLogin);
}
void CMainFrame::OnUpdateManageAdd(CCmdUI* pCmdUI)
{ pCmdUI->Enable(m_bItemAdd);
}
void CMainFrame::OnUpdateManagerChange(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_bItemChange);
}
void CMainFrame::OnSystemConnect()
{
CLoginDlg dlg;
if(dlg.DoModal()==IDOK)
{
m_bLogin=TRUE; m_bItemAdd=TRUE; m_bItemChange=TRUE; m_bItemSearch=TRUE;
}
}
void CMainFrame::OnSystemDisconnect()
{
db.Close(); if(m_pAdd) m_pAdd->DestroyWindow();
if(m_pChange) m_pChange->DestroyWindow();
//if(m_pSearch) m_pSearch->DestroyWindow();
m_bLogin=FALSE; m_bItemAdd=FALSE; m_bItemChange=FALSE; m_bItemSearch=FALSE;
}
void CMainFrame::OnDestroy()
{
CMDIFrameWnd::OnDestroy();
if(db.IsOpen()) db.Close();
}
void CMainFrame::OnManageAdd()
{
// 创建新子框架和视
m_pAdd=new CTheChildFrame(); /*
CCreateContext context;
context.m_pNewViewClass=RUNTIME_CLASS(CAddView);
if(!m_pAdd->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_PREFIXTITLE ,this, &context )) return;
m_pAdd->InitialUpdateFrame(NULL,TRUE);
m_bItemAdd=FALSE; // 禁止"增加新员工"功能*/
}
|
|
|
|
|
capture the telephone number
Some simple code example would be very appreciated !
capture the telephone number
Some simple code example would be very appreciated !
|
|
|
|
|
http://www.julmar.com/samples.htm[^] has some good examples as does the Platform SDK.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
Hi there!
I'm writing a language bar like app (plugin for a shell replacement) I can change input locale (keyboard layout)
using WM_INPUTLANGCHANGEREQUEST that works fine,
but i'd like to implement IME support (user can select conversion mode, input mode etc.)
The MS guy in the msdn forum told that it can be done only from inside the process so i've written the remote thread function and handling etc, now i can get a correct HIMC and aslo can get OpenStatus and ConversionStatus correctly but no menu items when calling ImmGetImeMenuItems
"Success, himc: 0x000904FB Conversion mode: 25 Sentence mode: 8 Num menu items: 0"
dwType = IGIMII_CMODE|IGIMII_SMODE|IGIMII_CONFIGURE|IGIMII_
TOOLS|IGIMII_HELP|IGIMII_OTHER |IGIMII_INPUTTOOLS;
dwFlags = 0; (also tried with IGIMIF_RIGHTMENU)
numOfMenuItems = pImmGetImeMenuItems(hIMC, dwFlags, dwType, NULL, NULL, dwSize);
It always returns 0 (
I call this right after ImmGetContext(hWnd) (hWnd is from FindWindow or GetForegroundWindow).
(i tried with notepad and the japanese ms-ime 2002)
Any trick or is something i do wrong? Or the language bar gets those menu items by some other way?
Please give some advice or sg, i'm tired of it, it makes me mad... no documentation, no examples aaargh... thanks, regards: Bagoj
p.s.: sorry my english is not correct (
|
|
|
|
|
Hi
Do anybody know what asycfilt.dll (system dll) is all about.
When i run my software (a video streaming software) on windows XP , it sometimes crash and XP default crash reporting dialog comes which says
Error occured in asycfilt.dll
Offset 00008988 etc.
so is there any way that i could judge the nature of error from this information , even if one get the detailed techinical report it is no more than bunch of assembly lines .
Unmanaged in a .NET world
|
|
|
|
|
During the processing of excel workbook in a VC program
when i open the workbook i'am currently processing the
application crashes. I have given exclusive access to
excel workbook in the program. The reason for crashing is
m_lpDispatch is becoming NULL. The Excel application that I'am opening manually is using the object through which my program accesses the excel services. Hence m_lpDispatch is becoming NULL.
Does any one has a solution
for this problem
|
|
|
|
|
Hi anybody has any inputs on Plugin Frameworks, some pointers articles would be helpful.
Regards
Tarun
Blue Pill or Red Pill........??
|
|
|
|
|
How about this one?
http://www.codeproject.com/dll/plugin.asp?target=plugin
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
There is my article about an MFC plug-in framework:
MFC plug-in architecture[^]
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
Hi all,
I have two threads, one thread call the other member function.
T1 :public CWinThread{
CCriticalSecion m_csLock;
public:
void dosmt{
if(csLock.Lock()){
................
csLock.Unlock
}
}
}
and T2:public CWinThread{
};
T1 t1;
T2 t2;
In t2 member functions calls t1.dosmt();
It works fine, but sometimes, it frezee in t2 context because of m_csLock.Lock never return. Is there any body know why?
Do Manh Hung,
|
|
|
|
|
You can't use a critical section on the stack. It must be visible to both threads. You can make it a static, which is probably the easiest solution.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Thanks Franks, but I I still have questions.
#1. if it must be visible to both threads, why doesn't it frezee immediately. It may run one day, two days before be blocked.
#2.
Is it OK if I declare a CCriticalSecion* pCS which refer to the m_csLock in T1. Then in T2, I use function pCS->Lock/Unlock? Is the m_csLock is visible to both thread?
Do Manh Hung,
|
|
|
|
|
Critical sections block all the time, that is their job. If you get a deadlock which is what you are talking about then that is a separate issue. This can be as simple as the code inside a CS getting into an endless loop and never returning. CS's should be used for the shortest amount of time and least amount of time as possible. You need to ensure try - catch is used and any exceptions always unlock the CS.
I suggest you go and read some heavy books on multithreading, thread synchronization, deadlocks etc. This is a very difficult area and unless you have a very good understanding of the basics you will have problems.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hi,
I want to hide a shortcut from desktop window. But I don't want to use hide attribute of file. I am using vc++. Can any one help me regarding this problem?
Thanks
Shoma
|
|
|
|
|
copy them into another directory, i don't know about any other way.
Don't try it, just do it!
|
|
|
|
|
Thanks for your reply. But I have to do it without moving shortcut file. Now I am concern about anly shortcut file but I have to do it for file and folders also.
If any one know anything about this then please help me.
Thanks a lot.
Shoma
|
|
|
|
|