|
I would like to remove focus editbox when user press Enter key(like Tab Key)
I can do it on create project by Dialogbase but can't do it on SDI
In CFormview
Now! I can't get Message for check press Enter key.
Please show example to me..
|
|
|
|
|
You can do this in PreTranslateMessage for the CFormView derived object.
You need to be careful, since some edit controls will WANT the enter key (if, for example, they are multiline).
Steve S
|
|
|
|
|
I found that both CInternetSession.OpenUrl(...) and CHttpFile.SendRequest(...) write cookies automatically after return. but I really want to control this by myself, or can I prevent wininet from writing cookies, and them let me use SetCookie(...) to do seperately?
by the way, I do it at syc mode, for someone says wininet asyc is not multithread-safe.
|
|
|
|
|
I would like to know how to programatically change change the colour of the text and background of the combobox's dropdown list.
Many Thanks
|
|
|
|
|
Hi All,
I have a touch screen application and on one part of this i need the user to set the time. I have a CDateTimeCtrl to show the time to be set and buttons numbered 0 to 9 to allow the user to set the text for this. I have tried sending WM_KEYDOWN/WM_KEYUP/WM_CHAR messages when the user clicks one of these buttons to set the time but this has no effect, can anyone help me with this.
Cheers
Andy
|
|
|
|
|
Check out MSDN. See the messages that CDateTimeCtrl processes.
Kuphryn
|
|
|
|
|
i want format a disk in a way of calling APIs or MFC method rather than calling like this:
ShellExecute(NULL, NULL, "format", "A: /v mylabel", NULL, SW_HIDE);
Hello World
|
|
|
|
|
SHFormatDrive could be your way...
Don't try it, just do it!
|
|
|
|
|
Thank you very much. However, calling SHFormatDrive will prompt a dialog, while i am planning to do the work in my own dialog, what should i do?
Hello World
|
|
|
|
|
I am a newbie to c++
How do i give commands to another exe file
Console application
I tryed
#include "stdafx.h"
#include "Shellapi.h"
int main
ShellExecute(this->m_hWnd,"open","notpad.exe ",
"c:\\hello.txt","",SW_SHOW );
return 0;
}
But i know thats rong
So how do i do it ?
All code plz
|
|
|
|
|
use createprocess.
Don't try it, just do it!
|
|
|
|
|
contemptx wrote:
But i know thats rong
How do you know? Is it producing an error?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,
I want to subclass the Edit used to write a SQL-Query in MS Access. The edit is of the special Access class "OKttbx".
Everything works, I injected a DLL into the Access-Process and the subclassing works just fine but I can't get the Windowtext of the control...
I tried the GetWindowText()-Function but I only get a pointer to stuff (lol). The call to GetWindowText() is in the subclassed WindowProc (in WM_PAINT) and it is definitely no problem of address spaces (as mentioned before I'm in the Access-Process).
Has somebody an idea how I can get this to work?
mfg Steven
|
|
|
|
|
Hello,
I have a semaphore controlled thread queue in my application. Now I have a problem to start my threads from the queue.
After call of _beginthread I get a thread-id not equal -1 and not equal 0, but my thread is not started (no trace message from thread, no break in breakpoint).
If I "help the application" with debugger "set next statement" to an other call of the _beginthread, I get an other thread-id (!= -1 && != 0), but thread is not started. In Taskmanager the threadcount is not inkremented.
Who can help me?
My application worked correcly under W2K. After compile the code with the .NET compiler the application works fine, besides on only one computer. But this computer is the machine, there must run the application
Can it be a problem with not correct installed framework or libraries ?
An important remember is, that the threats will be started correcly after restart the application. After some thread calls (between 10 and 100) it doesnt work. All threads terminated via _endthread() and in a good time (1-300 seconds).
Thanks for any helping
STP
|
|
|
|
|
Post the declaration of the callback function. Post the call to _beginthreadex().
Kuphryn
|
|
|
|
|
Good morning kuphryn,
there are more than one threadfuncs. All of this have the same prototyp:
void ThreadFuncName (void *args);
The application have one timer for each thread to start, but no thread should be run, if there an other running thread. To solve this, I use an self written thread-calling-queue. If a timer call, the corresponding thread would be add to my queue. The queue use a simple list and each element is a struct like this:
typedef void (*ThreadFunc) (void *args);<br />
<br />
typedef struct _THREADLIST_STRUCT {<br />
ThreadFunc ThreadFkt;
long ThreadId;
_THREADLIST_STRUCT *next;
} THREADLIST_STRUCT;
And I have an other timer (1 second). He looks in me queue and is there a thread in and no other running thread, he starts the first element.
unsigned long t_id = 0;<br />
<br />
t_id = _beginthread (m_Root->ThreadFkt, 0, m_pParent);<br />
if (t_id != -1) {<br />
} else {<br />
/ do an error message<br />
}
Each access of the internal thread-list (AddThread, DelThread, StartThread, ...) is protected via a semaphore. Each thread remove himself from the queue at the end of thread and call _endthread().
As I already said, I works !!!, but after 10-100 thread-calls, it doesnt work again. The _beginthread () return a value != 0 and != -1 -> no error message. But the thread is'nt called. This effect exist only on one machine. The only one, there it should work in real life. This machine have:
- W2K with latest SP's and Updates
- complete installed Visual Studio .NET 2002 German (we have some problems with the compiler in the actual VS.NET !!)
- SQLServer ODBC driver
- pcAnywhere 10.5
Thanks
Stephan
|
|
|
|
|
Interesting.
I think the problem is m_Root points to an invalid memory address.
You do not need to call_endthread(). Let the thread end on its on. If you keep track of it via a handle, then close the handle.
Kuphryn
|
|
|
|
|
Why does the application jumps into the catch (B* ex) and not the catch (D* ex) ?
The dynamic type of p is D and not B !
#include "stdafx.h"
class B
{};
class D : public B
{};
int _tmain(int argc, _TCHAR* argv[])
{
try
{
B* p = new D;
throw p;
}
catch (D* ex)
{
delete ex;
printf("catch (D* ex)\n");
}
catch (B* ex)
{
delete ex;
printf("catch (B* ex)\n");
}
return 0;
}
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
Object instance is of D but object type is B.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Because p is not a D*. It is a B*, which happens to be pointing to an instance of D. Nonetheless, the type of the pointer has not changed.
In other words, it's catching B* because that's what you're throwing. If you want it to catch D*, then you should throw D*.
e.g.: throw static_cast<D*>(p);
It's worth noting that you cannot use dynamic_cast here, because B is not considered a polymorphic type. i.e. It has no virtual functions.
|
|
|
|
|
Hi !
Here is a problem I'm not sure what would be the right way to solve it. I have a class which represents an operation and this operation has a duration. I want to be able to read the duration of the operation with the function getDuration(). As computing the duration is a long process, I don't want to do it before it is asked for, and I don't want to recompute it each time it is asked for. The code below is basically how I implemented it :
class Operation
{
public:
Operation() { m_DurationCalculated=false;} ;
~Operation();
long getDuration()
{
computeDuration();
return m_Duration;
};
private:
long m_Duration;
bool m_DurationCalculated;
void computeDuration()
{
if (!m_DurationCalculated)
{
m_Duration=;
m_DurationCalculated=true;
}
}
};
It works fine except that I want now the function getDuration() to be const, because, from an external point of view, getDuration() doesn't change the operation.
The problem, when making getDuration() const, is that it calls computeDuration(), which, I guess, should be const as well, and as m_Duration and m_DurationCalculated might be changed in a const function, I guess I have to put the mutable keyword in front of these member variables.
This is where I'm not sure : is it the correct way to solve this ? It looks strange to me that computeDuration, which really is not a const function, should be const in order to be called by the getDuration function.
What is the correct way to solve my problem ?
Thanks for your help !
Jerome
|
|
|
|
|
If you dont want to change computeDuration to constant function, you can follow this trick:
<br />
.........<br />
long getDuration() const{ <br />
((Operation*)this)->computeDuration();<br />
return m_Duration;<br />
}<br />
........<br />
|
|
|
|
|
Actually, I thought about this trick, but I would like to make sure that it is a correct way to handle this problem and I also wanted to know what would be the recommended way.
Jerome
|
|
|
|
|
Casting off the const-ness is a nasty hack. It's also undefined if the object you're casting was originally allocated as a const object.
A cleaner way to do it is to declare computeDuration as a const function, and declare m_Duration and m_DurationCalculated to be mutable (i.e. they can be modified by const functions).
e.g.
void computeDuration() const
{
// safe to modify mutable variables
}
mutable long m_Duration;
mutable bool m_DurationCalculated
|
|
|
|
|
Thanks for your answer.
I have another question regarding the constness of 'computeDuration()' : if I make it const, each function called in computeDuration would also have to be const which, in my real application would be at least 4 or 5 more functions. These functions are clearly modifying the object, but would have to be const. This seems strange to me. Is it the correct way to do it ?
Thanks !
Jerome
|
|
|
|