|
|
I have a "Dialogbox program" COriginDlg
I want to open a new dialog box CNewDlg -> using doModal()
In the new dialog box I want to access the original dialog box's variables etc.
Is this possible ??
WHen I try the following
BOOL CNewDlg::OnInitDialog()
{
CDialog::OnInitDialog();
COriginDlg dlg ; <------ ????
int i = dlg.Len ; <----- Try to access the variable 'Len' which is part of the class COriginDlg
< ERROR generated is "ACCESS VIOLATION" ???????
}
Any Ideas on how to do this properly ?
|
|
|
|
|
|
Does COriginDlg derived of CDialog?
|
|
|
|
|
Thanks for the reply.
Yes I think both are derived from CDialog
Both have:
class COriginDlg : public CDialog
class CNewDlg : public CDialog
------
Should I have derived CNewDlg from COrginDlg ???
|
|
|
|
|
sofa_2006au wrote: Should I have derived CNewDlg from COrginDlg ???
Only if CNewDlg is a COrginDlg .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No box are seperate Dialog box windows with list box controls etc
|
|
|
|
|
Then why would you ask, "Should I have derived CNewDlg from COrginDlg ???"
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello
I have a function whose signature is as follows: void Encrypt(char const* in, char* result, size_t n);
to call this function, I have written the following piece of code:
CString strValid = "Sample String";
char *szTemp = strValid.GetBuffer(strValid.GetLength());
strValid.ReleaseBuffer(-1);
char szDataOut[128] = "\0";
poMethod->Encrypt(szTemp,szDataOut,128);
This piece of code, works fine as desired in the DEBUG mode, but misbehaves in the RELEASE mode. I am unable find the subtle difference. I feel I am doing something wrong while intitialzing the char variables. Please help me out.
Thanx
|
|
|
|
|
1/ You use get buffer to give you a temporary pointer to your data, then release it again.
The releasebuffer member function may well move stuff about inside the string, invalidating the pointer you had - and that behaviour could be different in debug or release modes.
To say it differently...
szTemp is only valid between the GetBuffer () and ReleaseBuffer calls. After that, all bets are off.
2/ Secondly, you don't need to use GetBuffer / ReleaseBuffer at all, as the in parameter is const...
What's wrong with...
CString strValid = "Sample String";
char szDataOut[128] = "\0";
poMethod->Encrypt(strValid,szDataOut,128);
If you look at CString, it has a LPCTSTR operator, to give a const pointer, just like you need.
Iain.
|
|
|
|
|
Hello
I need to retrieve the ID of a process, but I only have a thread ID, I know that there is a funtion for that, GetProcessIdOfThread, bit it only works on Vista but I need it to work on Windows 2000, so I need the equivalent for this operating system.
Any help please?
Thank you very much
|
|
|
|
|
Have you tried with GetCurrentProcessId() ?
Regards,
Paresh.
|
|
|
|
|
Thanks, but I need the PID of another process, not the "current one"
|
|
|
|
|
GetProcessIdOfThread(OpenThread( THREAD_ALL_ACCESS ,false ,thread id))
|
|
|
|
|
What part of "I know that there is a funtion for that, GetProcessIdOfThread, bit it only works on Vista but I need it to work on Windows 2000..." did you not understand?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Have you been wasting time with that Gugel thing again
|
|
|
|
|
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
What I would do is, loop through all of the running process and the search for the process name, once found, i'll get the pid of that specific process. Something like this:
HANDLE h_pro;
HANDLE h_sna;
PROCESSENTRY32 pe_sen = {0};
int result;
int returnValue;
int counter = 0;
char* ProcessNames = Name;
h_sna = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (h_sna == INVALID_HANDLE_VALUE){
returnValue = -2;
return (returnValue);
}
pe_sen.dwSize = sizeof(PROCESSENTRY32);
try{
if (Process32First(h_sna, &pe_sen))
{
do
{
h_pro = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pe_sen.th32ProcessID);
CloseHandle (h_pro);
if (pe_sen.th32ProcessID != 0)
{
result = strcmp (pe_sen.szExeFile,ProcessNames);
if(result > 0){
returnValue = 0;
}
else if (result < 0){
returnValue = 0;
}
else
{
globalVariable = pe_sen.th32ProcessID;
break;
}
}
} while (Process32Next(h_sna, &pe_sen));
}
}
catch(...)
{
GetLastError();
}
CloseHandle (h_sna);
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
But if he only has a thread ID, how is he going to know what name to look for?
Iain.
|
|
|
|
|
|
Can anybody tell me how to disable Or Grayed ToolBar Item..
Thanks...
There Is Nothing Right & Wrong
|
|
|
|
|
Are you using MFC?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I used Crystal Report Viewer to load Crystal Report in VC++
Problem is when i type page number in Page Navigator (ToolBar) and hit enter, the default function (IDOK) is called instead of calling "OnGoToPageNClickedCrviewer1" function.
How to achieve this.
Thanks in advance.
|
|
|
|
|
Is it possible to create a docking output pane with tabbed view (looks like VC++ editor's output window) in scintilla...
very urgent
thanx in advance for any help!!!!!
|
|
|
|