|
time_t mktime(struct tm* ptr);
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
|
There's probably a simple explaination..
On my spin button when I press the down arrow it increments the integer value in an edit box and when I press the top arrow it decrements it. How do I fix it so that up means up and down means down!
Thanks.
|
|
|
|
|
Assign a variable of type CSpinButtonCtrl (, and SetRange32(...) ), then it becomes what you want it to be......
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Excerpt from MSDN for CSpinButtonCtrl
Anonymous wrote:
"
Note The default range for the spin button has the maximum set to zero (0) and the minimum set to 100. Since the maximum value is less than the minimum value, clicking the up arrow will decrease the position and clicking the down arrow will increase it. Use CSpinButtonCtrl::SetRange to adjust these values.
"
|
|
|
|
|
have a program that has two views . rich edit view and edit view . I have done some syntax coloring in the rich edit view. But the probelm is that when I use the keys ctrl-x and ctrl-v in edit view the program gives debug assertion failure sighting some error in the viewrich.cpp . Can anyone help me
Samir Sood
Samir Sood
|
|
|
|
|
|
Hi..
I write a miltithreaded MFC application so a worker thread
performs a lengthy operation.
I want the worker thread to notifty the UI thread when it
finishes the operation. So I use SendMessage()
function.
the code is something like this:
<br />
class CInfo
{<br />
public:<br />
HWND hwnd;<br />
}<br />
In the dialog class :
<br />
private:<br />
CWinThread* m_pThread;<br />
CInfo info;<br />
<br />
void CMyDlg::OnStartWorkerBtn()<br />
{<br />
info.hwnd=this->m_hWnd;<br />
m_pThread=AfxBeginThread(CWorker::Work,&info,<br />
THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);<br />
<br />
m_pThread->m_bAutoDelete=FALSE;<br />
m_pThread->ResumeThread();<br />
}<br />
<br />
void CMyDlg::OnWorkerMessage()<br />
{<br />
}<br />
The worker thread code:
<br />
UINT CWorker::Work(void* arg)<br />
{<br />
CInfo* info=(CInfo*)arg;<br />
<br />
<br />
<br />
SendMessage(info->hwnd,WM_USER+1,0,0);<br />
}<br />
The code works fine in the debug version but an ( Access
violation ) error occures in the release version when the UI
thread receives the message while dragging the window with the
mouse.
can any one help with that?
|
|
|
|
|
Have you tried PostMessage instead?, it does not look like you need your worker thread to be blocked anyway.
Here are the remarks for SendMessage:
"If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, Windows switches to that thread and calls the appropriate window procedure.
"
As to why this should be a problem?, i guess that is between God and Gates...
"It could have been worse, it could have been ME!"
|
|
|
|
|
thank you
but i do need to block the worker thread
any way the problem was solved
|
|
|
|
|
There are few problems that I see at the moment. First, don't use SendMessage betweem threads. It can lead to deadlocks. Use PostMessage or PostThreadMessage instead.
But your problem is not a deadlock, so this is only a suggestion.
I know that you HAVE to declare your custom messages handler function properly, because it can lead to such things like Access Violations in release versions. So I think this is your case. OnWorkerMessage should be full-declared, like this:
...
afx_msg LRESULT OnWorkerMessage(WPARAM wParam, LPARAM lParam);
ON_MESSAGE(WM_USER+1, OnWorkerMessage)
....
LRESULT CMyDlg::OnWorkerMessage(WPARAM , LPARAM )
{
...
}
Uncomment wParam and lParam if you want to use them
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
thank you Philip
it worked using SendMessage()
the problem was that I did not declare the function with parameters
thank you again
|
|
|
|
|
|
Hello guys!
there is a class named CMyClass as follow
CMyclass:CObject
{
public:
int m_iCount,m_iIndex;
CMyclass();
void ~CMyclass();
}
and definations: CMyclass ma,mb;
and statements: ma.m_iCount=3;
ma.m_iIndex=2;
How can I use "mb=ma;"?
Should I overide operator= ? and how?
Any suggestion is appreciable .
I'm learning learning and learning.
|
|
|
|
|
I just wrote a non-MFC code (actually a console one) to demonstrate operator overloading for you ...
#include <iostreamᡊe9ac73-238b-46be-991d-0f050c37248d
using namespace std;
class Base
{
protected:
static int _iIndex;
static Base* _pAddress;
int _iId;
Base* _pPrev;
public:
Base() {
_iId = ++_iIndex;
_pPrev = _pAddress;
_pAddress = this;
}
Base& operator==(Base& ref) {
ref._pPrev = this;
return *this;
}
int Bomb() {
cout << _iId << " -> ";
_sleep(500);
if(!_pPrev) {
cout << "\nChain broken!\n";
return 1;
}
return _pPrev->Bomb();
}
};
int Base::_iIndex = 0;
Base* Base::_pAddress = 0;
int main()
{
Base a[20];
a[19] == a[0];
return a[19].Bomb();
}
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
You don't need to overload operator =, because you'll get one for free - you only want to copy integral types (int).
Is you want to overload it, then by all means do so, like this
CMyclass & CMyclass::operator=(const CMyclass & toCopy)
{
m_iCount = toCopy.m_iCount;
m_iIndex = toCopy.m_iIndex;
return *this;
}
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Use copy constructor.
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
This is actually a trivial class, where you don't really need to overload operator=, since members are copied by default. If, however, your class contains pointers or references to objects, then you will need to overload the operator. This operator should always look for, and avoid, self assignments:
CMyclass & CMyclass::operator=(const CMyclass & toCopy)
{
if (this != &toCopy)
{
m_iCount = toCopy.m_iCount;
m_iIndex = toCopy.m_iIndex;
}
return *this;
}
|
|
|
|
|
And for copy constructor issue:
#include <iostreamᡊe9ac73-238b-46be-991d-0f050c37248d
using namespace std;
class Base
{
public:
Base() { }
int a;
Base(const Base& ref)
{
this->a = ref.a;
}
};
void main()
{
Base a;
Base b;
a.a = 3;
b = a;
cout << b.a << endl;
}
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Thank you ,Maxwell Chen and Christian Graus !
I overloaded operator= ,and it's ok with my program now.
|
|
|
|
|
You are welcome.
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Hi,
As it is possible to hide or disable the PropertyPage in the PropertySheet!
How do it!?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
I cover this in a demo in my MFC book (see sig). It's a fairly involved process, but here are the basic steps. Let me know if you need any additional help and I'll send you a demo app.
(All of these steps pertain to the property sheet class)
- Create a member variable to store the current tab index.
- Create an array member variable to hold all of the index values for the currently disabled tabs.
- Handle the
TCN_SELCHANGING notification message to set the current tab index.
- Handle the
TCN_SELCHANGED notification message to decide if you want to enable the tab to be activated. If you don’t, you must post a PSM_SETCURSEL message. In this message, the last active tab index is specified.
Cheers,
Tom Archer
Author - Inside C#, Visual C++.NET Bible
|
|
|
|
|
You could not, to told above, at once to send demo (VC5.0 or VC6.0) to me that I could understand better with the specified steps.
I still have questions be relative CPropertySheet , and I hope to find on them answers
Best regards,
Eugene Pustovoyt
pustovoyt@inbox.ru
|
|
|
|
|