|
I have an editor applications which should bring up a window or dialog with the list of keywords. Based on the selected keyword the window should show the appropriate controls in the window. Filling up input into these controls and clicking insert the keyword should get inserted into the editor.
PLease someone help with some ideas on this.
|
|
|
|
|
The simplest approach is, that you create all controls in Dialog editor. In OnInitDialog you parse the keywords and set CWnd::ModifyStyle(WS_VISIBLE, 0, 0) to appropriate controls. This function makes the controls invisible.
Robert-Antonio
"Love without sex is like a fish without antlers"
|
|
|
|
|
also, I would put each set into a vector collection so that for each collection you can use the iterator to iterate through each one and set the visibility appropriately.
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
I have seen some code recently in the Unreal Tournament public source code that uses types like "void(UObject::*Func)( FFrame& TheStack, RESULT_DECL );" and I am trying to figure out how to use this in my own code. I have written something like below but I always get the error "C2064: term does not evaluate to a function"
class A<br />
{<br />
public:<br />
void TestFunc()<br />
{<br />
printf("Hello\n");<br />
}<br />
};<br />
<br />
void Test(void(A::*Prm1)(void))<br />
{<br />
Prm1();<br />
}<br />
<br />
int main(int argc, char **argv)<br />
{<br />
Test(A::TestFunc);<br />
<br />
return 0;<br />
}
It won't even let me cast it to a DWORD or any other types but you must be able to do something with it or it would not exist. So is there anyone here who can tell me how to use this (I dont even know what to call it), I have tried searching but all the search engines that I have tried have problems with "::*".
|
|
|
|
|
Try this:
class A
{
public:
void f() { printf("Hello\n"); }
};
void Test(void (A::*fun)(void))
{
A a;
(a.*fun)();
};
void main()
{
Test(&A::f);
}
If you call a non-static function via pointer-to-member, you have to specify a instance of class, that is passed to the member function.
Robert-Antonio
"Love, truth and electric traction must gain victory over hate, lie and
diesel traction."
|
|
|
|
|
Thanks alot, thats what I needed.
|
|
|
|
|
Hi,
I am writing an application that can do the following
1. Start an application
2. Open up a dialog box in the application
3. Write a message into a text dialog box and commit it.
I am having a problem with step 3. How do I pass along a string to write to a dialog box that is in focus. If this question has already been asked before, can you send me a pointer? Thanks.
Lohith
|
|
|
|
|
that means u wnat to update the edit box with some string?
ALL THINGS ARE POSSIBLE UNTIL THEY ARE PROVED IMPOSSIBLE-AND EVEN THE IMPOSSIBLE MAY ONLY BE SO,AS OF NOW
|
|
|
|
|
Get window handle of the text box and use SetWindowText.
Then send dialog a command message for the OK button press.
|
|
|
|
|
hi all,i have a problem with suspending a process.
Could someone help me?
Thanks a lot!
|
|
|
|
|
I expect we will be able to help you if you tell us what the problem is.
Mike
|
|
|
|
|
here are some code used to suspend a process. since I do not known the exact problem you meet, I only show it for you:
BOOL WINAPI SuspendProcess(DWORD dwProcessID, BOOL bSuspend)
{
// 取得OpenThread函数的地址
typedef HANDLE (__stdcall *PFNOPENTHREAD)(DWORD, BOOL, DWORD);
HMODULE hModule = ::GetModuleHandle("kernel32.dll");
PFNOPENTHREAD OpenThread = (PFNOPENTHREAD)::GetProcAddress(hModule, "OpenThread");
if(OpenThread == NULL)
return FALSE;
// 取得指定进程内的线程列表
HANDLE hSnap;
hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, dwProcessID);
if(hSnap != INVALID_HANDLE_VALUE)
{
// 遍历线程列表
THREADENTRY32 te = { 0 };
te.dwSize = sizeof(te);
BOOL bOK = ::Thread32First(hSnap, &te);
while(bOK)
{
if(te.th32OwnerProcessID == dwProcessID)
{
DWORD dwID = te.th32ThreadID;
// 试图打开这个线程
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, dwID);
if(hThread != NULL)
{
// 暂停或者唤醒这个线程
if(bSuspend)
::SuspendThread(hThread);
else
::ResumeThread(hThread);
::CloseHandle(hThread);
}
}
bOK = ::Thread32Next(hSnap, &te);
}
::CloseHandle(hSnap);
}
return TRUE;
}
I am a Chinese man, so the commentary is in Chinese.
Regards
|
|
|
|
|
1.what's type in fact?
we often write code like this :
typedef struct _M_{
int a;
char b;
}M;
M m;
m.b = 'w';
here is the question ,how C++ compiler treat M?How to get the address of m(I mean how compiler can)?and the offset of M::b?
2.template<class T>
class A{
T t;
};
case T is a structure,how can I visit every element of the struct T?
3.RTTI
How can I know the type of a variable at runtime?typeid can get its name,but what I need is the real type,not its name.
|
|
|
|
|
1. the compiler treat M very nicely; &m is the address, as for the other, I don't know.
2. huh ? without knowing the class/struct; with a class declaration, you can't ( but I must be wrong )
3.you can't. the best you can do if find if it matches an existing type; with dynamic_cast<type>, you will know if the variable is of type Type.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
1. A struct definition is a way to tell the compiler that: Whenever a variable of type struct is declared, it must allocate memory, at least, the size that the struct definition defines.
Let's declare a struct:
typedef struct tagMyStruct
{
int theInteger;
char theCharacter;
}
MyStruct;
Then we declare a variable of this type:
MyStruct theVariable;
char * pointerToCharacterMember;
theVariable.theInteger = 42;
theVariable.theCharacter = 'A';
When the compiler handles the variable declaration, it must find an offset in memory to put it. Let's say it puts it at 0x0001000.
For sizeof(MyStruct), the compiler should return sizeof(int) + sizeof(char), which is 4 + 1.
For simplicity of the example, I've chosen to use pointers. Let's do this:
pointerToCharacterMember = &theVariable.theCharacter;
To get the address that pointerToCharacterMember should point to, the compiler gets the address of theVariable. To get the address of the member theCharacter, it must add the size of the member theInteger. So the address pointed to by pointerToCharacterMember, should be 0x0001004.
In memory the variable would look like this:
memory offset Value
-------------- --------------
0x00001000 0x2A ; This is where theVariable is placed, it is also the address of theInteger.
0x00001001 0x00
0x00001002 0x00
0x00001003 0x00
0x00001004 0x41 ; This is the address of theCharacter
Now, I've actually lied to you all the time , the sizes and addresses are not computed exactly like this, because the compiler optimizes for running on CPU's that prefer variables to start on certain boundaries.
So the size of our struct would NOT be sizeof(int) + sizeof(char), but rather sizeof(int) + (n bytes) + sizeof(char) + (n bytes).
2. You can't. The compiler takes all your method names and variable names and translates them into addresses. When the code is compiled, there will be no such thing as a class A, the objects exists solely on design time, and besides RTTI, there is no nifty runtime features like the reflection APIs in Java and .NET.
3.Wiltein wrote:
but what I need is the real type,not its name.
But you've allready GOT the real type, otherwise you couldn't get it's name!?...
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi…
How r u?
What’s going on? Hope every thing is well.
I need any idea in VC++.
Background: There is a form or dialog which is picking too many values from database & taking time to manipulate those values.
Problem: Now I want to retain or save all values in all controls on dialog when second time user open that dialog instead of reload from database.
Question: Is there any class can be used to retain all values of all controls on dialog & can be retain on next opening of dialog.
If you have any idea, please let me know. I’m waiting…
OK! Have a nice day.
With Best Regards
Sumit Kapoor
Never consider anything impossible before trying to solve that..---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
There's no automatic way that I know of, you need to do this manually.
I did something similar, I keep the variable in static member variable for each class that I create; so that the values are kept; but that only works within one "run" of the program, if you need them to work between "runs" you will need to save them on disk, either in a registry or in a file.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You will probably need to make a simple text file. This can be done by using serialization. I haven't done any serialization stuff in a while, so I'm kinda rusty. But I did it in a CFormView-derived class. In the CDocument's save, I also used the CArchive member to serialize my objects that I wanted returned to their previous state. I think if you do this you will also have to change IMPLEMENT_DYNAMIC and DECLARE_DYNAMIC to IMPLEMENT_SERIAL and DECLARE_SERIAL.
Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store
My articles[^]
bdiamond
|
|
|
|
|
Hi,
Thanks for suggesting me solution,
I used following article for saving data,
http://www.codeproject.com/dialog/dlgset.asp
This article use trick & save all control's data in registry.Nice one.
Thanks again
Have a Nice Life.
Sumit Kapoor
Never consider anything impossible before trying to solve that..---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
it fails to retrieve newly intruduced data by the user.
i tried this ...
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
UpdateData(FALSE);
and this..
CDHtmlDialog::GetElementText(_T("email"));
if(CDHtmlDialog::GetElementText(_T("email")))
{
EDIT1=_T("works");
}
else
{
EDIT1=_T("it doesn't work");
}
i tried many combination and searching answer, but i can't find one right.
this is qwhat i do on init
BOOL Cfirstw32mfcDlg::OnInitDialog()
{
..
..
..
...
EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login");
EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details here..");
UpdateData(FALSE);
//EDIT1=("");
//EDIT2=("");
UpdateData(FALSE);
return FALSE; // return TRUE unless you set the focus to a control
}
EDIT1 and EDIT2 contain values, either from the register or the alternative 'default value'and it wil be displayed in the userinterface
it's also visible in the userinterface, but if i intruduce values manualy and press ok,
'UpdateData(FALSE);' doesn't update anything, nor UpdateData();,UpdateData(TRUE); or UpdateDialogControls(this, FALSE);
i tried resting the values as u can see, but than the entries in the registry are also empty
what am i doing wrong here
thanx for your time and kind regards,
marco
// firstw32mfcDlg.cpp : implementation file
//
#include "stdafx.h"
#include "firstw32mfc.h"
#include "firstw32mfcDlg.h"
#include ".\firstw32mfcdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// Cfirstw32mfcDlg dialog
BEGIN_DHTML_EVENT_MAP(Cfirstw32mfcDlg)
DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
DHTML_EVENT_ONCHANGE(_T("email"), OnEnChangeEdit1 )
DHTML_EVENT_ONCHANGE(_T("password"), OnEnChangeEdit2 )
END_DHTML_EVENT_MAP()
Cfirstw32mfcDlg::Cfirstw32mfcDlg(CWnd* pParent /*=NULL*/)
: CDHtmlDialog(Cfirstw32mfcDlg::IDD, Cfirstw32mfcDlg::IDH, pParent)
//, m_EDIT1(0)
//, m_EDIT2(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void Cfirstw32mfcDlg::DoDataExchange(CDataExchange* pDX)
{
CDHtmlDialog::DoDataExchange(pDX);
DDX_DHtml_ElementInnerText(pDX, _T("email"), EDIT1);
DDX_DHtml_ElementInnerText(pDX, _T("password"), EDIT2);
DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text1"), m_EDIT2);
DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text2"), m_EDIT2);
}
BEGIN_MESSAGE_MAP(Cfirstw32mfcDlg, CDHtmlDialog)
ON_WM_SYSCOMMAND()
//}}AFX_MSG_MAP
//ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
//ON_EN_CHANGE(IDC_EDIT2, OnEnChangeEdit2)
END_MESSAGE_MAP()
// Cfirstw32mfcDlg message handlers
BOOL Cfirstw32mfcDlg::OnInitDialog()
{
CDHtmlDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//EDIT1=("");
//EDIT2=("");
EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login");
EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details here..");
UpdateData(FALSE);
//EDIT1=("");
//EDIT2=("");
UpdateData(FALSE);
return FALSE; // return TRUE unless you set the focus to a control
}
void Cfirstw32mfcDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDHtmlDialog::OnSysCommand(nID, lParam);
}
}
void Cfirstw32mfcDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDHtmlDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR Cfirstw32mfcDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
HRESULT Cfirstw32mfcDlg::OnButtonOK(IHTMLElement* /*pElement*/)
{
CDHtmlDialog::GetElementText(_T("email"));
if(CDHtmlDialog::GetElementText(_T("email")))
{
EDIT1=_T("works");
}
else
{
EDIT1=_T("it doesn't work");
}
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
GetElementText(_T("password"));
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
OnCancel();
//AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
//AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
//OnOK();
//return S_OK;
return NULL;
}
HRESULT Cfirstw32mfcDlg::OnButtonCancel(IHTMLElement* /*pElement*/)
{
GetElementText(_T("email"));
if(GetElementText(_T("email")))
{
EDIT1=_T("works");
}
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
GetElementText(_T("password"));
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
OnCancel();
return S_OK;
//return 0;
}
HRESULT Cfirstw32mfcDlg::OnEnChangeEdit1(IHTMLElement* /*pElement*/)
{
//CDHtmlDialog::GetElementText(EDIT1);
//UpdateDialogControls(this, FALSE);
//UpdateData(FALSE);
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
return FALSE;
}
HRESULT Cfirstw32mfcDlg::OnEnChangeEdit2(IHTMLElement* /*pElement*/)
{
//UpdateData(FALSE);
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
return FALSE;
}
// firstw32mfcDlg.h : header file
//
#pragma once
// Cfirstw32mfcDlg dialog
class Cfirstw32mfcDlg : public CDHtmlDialog
{
// Construction
public:
Cfirstw32mfcDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_FIRSTW32MFC_DIALOG, IDH = IDR_HTML_FIRSTW32MFC_DIALOG };
CString EDIT1;
CString EDIT2;
CString m_EDIT1;
CString m_EDIT2;
CString m_TEMP_EDIT1;
CString m_TEMP_EDIT2;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
HRESULT OnButtonOK(IHTMLElement *pElement);
HRESULT OnButtonCancel(IHTMLElement *pElement);
HRESULT OnEnChangeEdit1(IHTMLElement *pElement);
HRESULT OnEnChangeEdit2(IHTMLElement *pElement);
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
DECLARE_DHTML_EVENT_MAP()
public:
//char m_EDIT1;
//char m_EDIT2;
//afx_msg void OnEnChangeEdit1();
//afx_msg void OnEnChangeEdit2();
};
it gives a headache, knowing so much and stil not knowing anything
|
|
|
|
|
I think you can go for simple registry class known CRegKey defined in atlbase.h
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
no it works wel, but not when i click the button.
BOOL Cfirstw32mfcApp::InitInstance()
{
SetRegistryKey(_T("Natural_Demon"));
..
..
}
// this part works wel
EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login");
EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details here..");
UpdateData(FALSE);
this part work wel also, i faild the retireve the data from the interface, although i use"UpdateData(FALSE);"
i can paste it anywhere in the script, but if i use this "Cfirstw32mfcDlg::OnButtonOK()"
HRESULT Cfirstw32mfcDlg::OnButtonOK(IHTMLElement* /*pElement*/)
{
UpdateData(FALSE);
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
return FALSE; // return TRUE unless you set the focus to a control
...
..
}
it fails to retrieve the fresh data
kind regards,
marco
|
|
|
|
|
Hi
In my application i am using createprocess() function to run an exe. once if i close the application, process will get terminated automatically. thats fine. but if i call openprocess() with that old process id,still it is returning some non null process handle. this is there only in windows xp (not in windows 2000,etc).i need solution for this issue
Thanks
JP
ALL THINGS ARE POSSIBLE UNTIL THEY ARE PROVED IMPOSSIBLE-AND EVEN THE IMPOSSIBLE MAY ONLY BE SO,AS OF NOW
|
|
|
|
|
|
Hello
I create a MFC aplication, and in my cpp file, i define a variable C++
string str;
I know that, i can use CString, but i want to know why it appears "error link"
when i compile project, it appears error (error link) like that
"Linking...
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >(void)" (??1?$basic_strin
g@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in ocl.lib(ora.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >(class basic_string<char,s
truct std::char_traits<char="">,class std::allocator<char> >::allocator<char> const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$allocator@D@1@@Z) already defined in ocl.lib(ora.obj)
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
Bin/BMSOracleView.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
"
|
|
|
|
|