|
Irish_GUI wrote:
has anyone got the active x component to work correctly
in unmanaged c++ (mfc 7.1) in visual studio.net 2003 ?
Not tried it yet as I haven't the funds to upgrade. What kind of problems are you running into?
Have you tried any of the samples that come with Crystal.
Michael
CP Blog [^]
|
|
|
|
|
I have been trying to implement the MRU option for a MFC Dialog program. I have a Menu for New, Open, Save etc, but would like to add a Menu option for MRU files.
All the examples are based on SDI or MDI MFC applications.
The Menu is defined in the AppDlg.cpp file but LoadStdProfileSettings(); is not a member of this dialog class, only the App.cpp class.
Are they any dialog based samples, even the Microsoft site uses a SDI example.
|
|
|
|
|
I have been trying to implement the MRU option for a MFC Dialog program. I have a Menu for New, Open, Save etc, but would like to add a Menu option for MRU files.
All the examples are based on SDI or MDI MFC applications.
The Menu is defined in the AppDlg.cpp file but LoadStdProfileSettings(); is not a member of this dialog class, only the App.cpp class.
Are they any dialog based samples, even the Microsoft site uses a SDI example.
|
|
|
|
|
Hello,
I am creating an application in MFC which, among many other features, has to perform keyboard input processing.
My question has to do with the fact that the custom control that I am coding has to take in account what the state of INSert/OVeRwrite is (as seen in the status bar). I would like to know if it is possible to know this without having to listen to ALL the keyboard input. Can anyone give me a hint? That would be much appreciated.
David Nimrod
|
|
|
|
|
In OnKeyDown catch the Insertbutton then set a bool to true/false?
just an idea.
good luck!
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Just for clarification, why does your application care about the state of the INS key?
I've seen a few applications that use this implementation.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The application I am developing uses several Custom Controls (which I am also working on) and (mostly) all these controls accept keyboard input. Because of this fact and also because I want to provide the user with the best * standard * input interface I can, I have to allow overwrite/insert at the current cursor position, among many other features (such as cut&past, drag&drop, etc, etc).
I was asking if it is possible to know (in a simple way) what the state of INS/OVR is without having to recur to a (main) Keyboard Listener, which in turn would set Global flags on/off.
I take it there is not.
dNimrod#X
________________________
|
|
|
|
|
dNimrod#X wrote:
I was asking if it is possible to know (in a simple way) what the state of INS/OVR is without having to recur to a (main) Keyboard Listener, which in turn would set Global flags on/off.
I take it there is not.
But there is. Try:
if (GetKeyState(VK_INSERT) == 0x01)
AfxMessageBox("Key is down");
else
AfxMessageBox("Key is up");
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
No, you are not understanding my question. Allow me to rephrase:
I need to know whether Text Insert is on or not, meaning if text should be appended (inserted) or overwritten at the current cursor position.
I don't want to know whether a certain key is being pressed or not -- that is out of the scope of the question.
Up till now, the only possible solution I have thought of would be to add a keyboard listener at the application level, which would in turn set 1 boolean variable on/off. Something like: bOverstrike = true/false
To avoid all this, I was wondering if there is either a MFC or a Win32 API function which automatically deals with text overwrite/insert.
Do you [or does anyone] know about such a feature?
David Nimrod
|
|
|
|
|
dNimrod#X wrote:
I need to know whether Text Insert is on or not, meaning if text should be appended (inserted) or overwritten at the current cursor position.
Which is exactly the solution I provided you.
dNimrod#X wrote:
I don't want to know whether a certain key is being pressed or not -- that is out of the scope of the question.
Actually, that is the root of the question - whether the INS key is on or off.
dNimrod#X wrote:
Up till now, the only possible solution I have thought of would be to add a keyboard listener at the application level, which would in turn set 1 boolean variable on/off. Something like: bOverstrike = true/false
Implementing a keyboard hook or checking the status when it is needed, the net result is the same - a global variable being set.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The task manager does not promise cleanup when you end the process from the Processes tab. In fact, it wafrns you that some DLL's may not shut down, etc, etc.
The only reason someone would want to "End Process" on your app is because your app crashed and locked up. The only fix for that is writing better code so that the user doesn't have to use the "End Process" button.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I am trying to have a overlapped blocking pipe write so that I can have either data sent signal or a timeout signal... The code I have written is as follows
<br />
DWORD dwMode = PIPE_READMODE_MESSAGE | PIPE_WAIT;<br />
BOOL bSuccess = ::SetNamedPipeHandleState(m_hPipe, &dwMode, NULL, NULL);<br />
and my pipe write function have code
<br />
OVERLAPPED op = {0};<br />
op.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);<br />
<br />
bSuccess = ::WriteFile(m_hPipe, lpBufferPos, dwToWrite,<br />
&dwNumberOfBytesWritten, &op);<br />
<br />
if(bSuccess)<br />
{<br />
return TRUE;<br />
}<br />
else<br />
{<br />
m_dwLastError = ::GetLastError();<br />
if(m_dwLastError == ERROR_IO_PENDING)<br />
{<br />
switch(WaitForSingleObject(op.hEvent, m_dwTimeOut))<br />
{<br />
case WAIT_OBJECT_0:<br />
return TRUE;<br />
break;<br />
case WAIT_TIMEOUT:<br />
m_dwLastError = ::GetLastError();<br />
return FALSE;<br />
case WAIT_FAILED:<br />
m_dwLastError = ::GetLastError();<br />
return FALSE;<br />
break;<br />
}<br />
}<br />
else<br />
{<br />
return FALSE;<br />
}<br />
} <br />
}<br />
The problem that I am facing is that all my Write to pipe function calls keeps returning with TRUE code and the corresponding first Read call in the child process remains locked at the WaitForSingleObject call and then after some write pipe operation in the parent process Read returns with "More data is available" error.
Can anyone direct me what I am doing wrong.
|
|
|
|
|
PS> what I need is a blocking write with a timeout so that if no read is performed for a specified time the thread unlocks.
|
|
|
|
|
Hi there! The thing I would like to know is how to lock and unlock a single variable, such as int or double? All these semaphores and events must be declared within a class, but how can I do it with simple types?
|
|
|
|
|
You still have to use at least a Critical Section to lock against while accessing the simple type.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hmm, I've found InterlockedExchange and I guess that's what I need. By the way, what will happen if I read variable's value in one thread and write to it from another thread using InterlockedExchange, something like this:
bool yes_no; //Common variable
void Thread1Func()
{
bool tmp;
tmp=yes_no;
}
void Thread2Func()
{
InterlockedExchange((LPLONG)&yes_no,true);
}
So, if thread 1 get's to yes_no first is it going to work correctly?
|
|
|
|
|
Assuming that Thread 1 has to wait until Thread 2 has updated the data then no it is not guaranteed to work.
Have you thought about using events?
Wait for the event in Thread 1 (before the read of the variable) then signal the event in Thread 2 after the variable update.
This will ensure the data is current when Thread 1 comes to read it.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Can i delete an object using free(); which was allocated using operator new ?
|
|
|
|
|
xcavin wrote:
Can i delete an object using free(); which was allocated using operator new ?
I think the first question is why you would want to. Mixing C and C++ memory allocation isn't exactly the best way of writing solid code.
Michael
CP Blog [^]
|
|
|
|
|
Michael P Butler wrote:
the first question is why you would want to.
I never want to do that. But this was asked to me in an interview. I replied the object's destructor will not be called when free() is used.
I just wanted to know if there is any other views on this issue.
|
|
|
|
|
This is correct, the class destructor isn't called if you attempted to use free(), and therefore your answer is NO!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I opend an INF file by SetupOpenInfFile.
To query values and fields of keys I used SetupGetLineText and SetupGetStringField.
I know entry section name. So I can enumarate all other section and key values.
But how can I get a key name by its index number in known section?
We know that INF file structure is same as:
[Section1]
Key1=value1
key2=value2
...
|
|
|
|
|
I have 2 class - CUserDlg,CMenuDlg. I collect a string value from CUserDlg and pass/use this value to/in CMenuDlg.
I define the variable as Public in CUserDlg and Collect value for it.
Public : CString szName;
UserDlg.Cpp:
szName = "Hai";
CDialog::EndDialog(0);
CMenuDlg dlg;
dlg.DoModal();
and close CUserDlg screen and calls CMenuDlg screen.
I define CUserDlg object in MenuDlg header file.
CUserDlg* UserData;
And when I access UserData->szName in CMenuDlg.Cpp file, i get only NULL value.
Pls help me out.
|
|
|
|
|
sugumar wrote:
I define CUserDlg object in MenuDlg header file.
CUserDlg* UserData;
And when I access UserData->szName in CMenuDlg.Cpp file, i get only NULL value.
Where do you assign the original CUserDlg pointer to the UserData pointer. I usually pass the pointer via the constructor, but your code doesn't appear to do that.
Roughly,
UserDlg.cpp
CUserDlg::OnOK()<br />
{<br />
CMenuDlg dlg(this)<br />
dlg.DoModal()<br />
}
CMenuDlg.h
class CUserDlg;<br />
<br />
class CMenuDlg : public CDialog<br />
{<br />
public:<br />
CMenuDlg(CUserDlg* pUserDlg, CWnd* pParent = NULL);
<br />
private:<br />
CUserDlg* m_pUserDlg;<br />
}
CMenuDlg.cpp
#include "UserDlg.h"<br />
<br />
CMenuDlg::CMenuDlg(CUserDlg* pUserDlg, CWnd* pParent)<br />
{<br />
m_pUserDlg = pUserDlg;<br />
}
Then when you want to access szName
void CMenuDlg::SomeFunc()<br />
{<br />
CString temp = m_pUserDlg->szName;<br />
}
Michael
CP Blog [^]
|
|
|
|
|
thanks for your immediate response and which also solves my problem.Tnahk You Michael
|
|
|
|