|
Pazzuzu wrote:
I would like to send a message function from 1 Dialogue to another dialogue...
Can you use SendMessage() or PostMessage() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The Problem for me is I have created different tabs deriving from a CDialog object. I have 2 command buttons "OK" & "Cancel" & they reside in a dialog window(Not part of tabs dialog)
class C_TabControl : public CTabCtrl
{
// Construction
public:
CDialog *m_tabPages[13]; // Here Iam creating my tabs
So when the user presses "OK" by changing something in the tabs,I want to send a "function call" from the " C_TabControl" object to the tab.
As the Tabs are derived from CDialog,I can't define a function in the tab & call it using m_tabPages[0].
the compiler will complain that the "userdefinedfunction" not defined in CDialog.
So was looking for a function in CDialog which I can override to accomplish this purpose.
|
|
|
|
|
The Problem for me is I have created different tabs deriving from a CDialog object. I have 2 command buttons "OK" & "Cancel" & they reside in a dialog window(Not part of tabs dialog)
class C_TabControl : public CTabCtrl
{
// Construction
public:
CDialog *m_tabPages[13]; // Here Iam creating my tabs
So when the user presses "OK" by changing something in the tabs,I want to send a "function call" from the " C_TabControl" object to the tab.
As the Tabs are derived from CDialog,I can't define a function in the tab & call it using m_tabPages[0].
the compiler will complain that the "userdefinedfunction" not defined in CDialog.
So was looking for a function in CDialog which I can override to accomplish this purpose.
|
|
|
|
|
What's wrong with:
class CMyDialog : public CDialog
{
public:
userdefinedfunction();
};
class C_tabControl : public CTabCtrl
{
public:
CMyDialog *m_tabPages[13];
};
m_tabPages[13]->userdefinedfunction();
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks for your suggestion.Guess,Have to work in that direction.
|
|
|
|
|
|
Hi
i make 1 instance of CMyClass in the ThreadProc function and call Init member function :
int CMyClass::Init(int ID)<br />
{<br />
m_ChID=ID;<br />
int res=pInitChannel(m_ChID);<br />
<br />
if(0==res)<br />
return true;<br />
else<br />
{<br />
ReportError(res);<br />
return false;<br />
}<br />
}
I know (and correct me if wrong) that the ID parameter and m_ChID are safe.
I mean that if i pass 0 from a thread and 1 from another then there is no chance that m_ChID member will have the same value 0 or 1 for both instances since m_ChID is not a shared variable..
the problem that arises that the library i call (which have the global pInitChannel function) should be thread safe but i get an error that indicates that I pass the same ID more than once (which is not allowed).
now the question is :
Am I wrong with my concepts or does the library i use have problems with multithreading ?
thank you for reading
|
|
|
|
|
hello,
I use MFC and new I need to create controls (buttons) on-the-fly and add message
handlers to them for the BN_CLICKED event at the time they are created. I see how
the messagemap functionality can add handlers for the controls that I already
have on my form, but what about dynamically created.
I do not wish to create an excessive amount of controls and just hide the
ones that are inappropriate at the time..
(cause: where di I set the limit as to what is a safe amount of controls then..)
thankful for any help I can get.
|
|
|
|
|
Hi,
You can intercept the button down message (WM_LBUTTONDOWN) or any button in the PreTranslateMessage(MSG* pMsg):
BOOL CYourDialog::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_LBUTTONDOWN)
{
CWnd *wnd = CWnd::FromHandle(pMsg->hwnd);
int ID = wnd->GetDlgCtrlID();
if(ID == IDC_OWNBUTTON1)
{
MessageBox("IDC_OWNBUTTON1");
return TRUE;
}
if(ID == IDC_OWNBUTTON_N)
{
MessageBox("IDC_OWNBUTTON_N");
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
The IDC_OWNBUTTON1 ... IDC_OWNBUTTON_N is an custom control id's
Ivan Cachicatari
www.latindevelopers.com
|
|
|
|
|
Hello,
I'm trying to create a system modal window on Windows 2000. But, it is not lock desktop. How can I create a system modal dialog box like "shutdown dialog" on Windows 2000? Thank you.
Regards,
Orkun GEDiK
System & Software Support Specialist (SAP R/3)
ASTRON
|
|
|
|
|
Do you mean something like:
MessageBox(..., MB_SYSTEMMODAL)
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi..
I'm using Global variable in VC++ MFC by declaring variable in .cpp file. then I've to use "extern" to acces that variable from other file..that's OK!..if I'm working normal..But when I use to access that Variable from thread..then It gives Error in Relase varsion(NOTE: not giving error in DEBUG version)..
1. Whenever I need to write new value I use CCriticalSection variable & Lock & unlock while operation of writing..
e.g:
CCriticalSection a1;
a1.Lock();
bStopRightDownThread=true;
a1.Unlock();
2. This value is Continue used by thread & checked by thread..if this value change then thread take action as per value...
Problem : It is giving Illigal Operation error & close application in case of RELEASE version, but working fine in case of DEBUG version.
WHAT DO YOU THINK REASON OF THIS?
THanks..I'm waiting for your reply...
---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
You can try this:
From thread post/send message which calls a function from your class which will set your variable.
I once had something similar and we thought the reason was that a thread works on a different part of memory. (but I'm not sure)
Hope this helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Your code for using a critical section is flawed. What you have there won't do anything. The critical section object must be shared just like the boolean you're trying to modify:
CCriticalSection _bStopRightDownThread;
bool bStopRightDownThread;
...
_bStopRightDownThread.Lock();
bStopRightDownThread = true;
_bStopRightDownThread.Unlock(); The fact that it produces an error in the release version but not in the debug version is (in my experience) totally coincidental.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ya..Dear,
Ya Dear your are right, I'm facing problem in release version,not in Debug.
But can you give more clear idea..how to do?
// Take these as Global
CCriticalSection _bStopRightDownThread;
bool bStopRightDownThread;
.....
.....
.....
// In particular function use as follow
_bStopRightDownThread.Lock();
bStopRightDownThread = true;
_bStopRightDownThread.Unlock();
Do Your means this?
If yes..then I'm using this in many files, DO u means I've to share Critical section vaiable to all using:
extern CCriticalSection _bStopRightDownThread;
or induvaully declare in all files..
PLz Gide a One step more..
Thanks for reply..
---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
If you are sharing a global variable, then you must share the critical section as well. Each function must lock the same critical section, otherwise they don't do anything. So you'll have to define it as extern if it's used in multiple files.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I am stuck up with a small problem. I am making an application (Explorer style), where there is a ROOT NODE, various PARENT NODES below it & CHILD NODES below PARENT NODE.
The problem is that the tree is kindof hardcoded, means there is no registery or file or database to read form & populate the tree. I know what all nodes are there and their hierarchy & have to populate the tree at startup.
But at the same time I have to make the code as generic as possible so that in furture it should be easy to add a new node at any level.
Is there some way to generalize this ?
Or for every item I will have to go through the painfull process of "LoadIcon", "Add" & "InsertItem"
|
|
|
|
|
Well you need two things. Somewhere to store the information so that it can be edited easily and a mechanism to read that data and populate the tree. This could happen at runtime or at build time by generating code from the data.
You could store the data in the registry, an xml file, a custom format text file, a database etc etc
If you go with a runtime solution then you run the risk that the user will modify the data, if you do it at build time you dont have that problem.
Why dont you make a function that calls LoadIcon, Add, InsertItem etc and just call that. Then you would only need to add extra calls to this function to add extra items
|
|
|
|
|
Thankx. I am working on this solution but the problem is that for this I had to make a "array" having the following elements;
UINT iResourceId; // Resource ID used in LoadIcon
UINT iMask; // Used in TVINSERTSTRUCT
char strNodeText[20]; // Used in TVINSERTSTRUCT
bool bChildPresent; // Used in TVINSERTSTRUCT
tTreeNodeEnum eTreeNodeEnum; // Unique value passed in lParam of
// TVINSERTSTRUCT, to detect which node is
// clicked
There are 2 problems to this approach.
1) Population of the array at start-up
2) I still have to keep a track of the parent nodes & the childs within the parent node. coz u have to pass a parent handle to the TVINSERTSTRUCT.
Any comments / suggestions ?
|
|
|
|
|
Im happy to help on the condition that you attempt to use the English language correctly. Thankx is not a word, nor is it an abreviation of any word in the English language. In fact its not an abreviation at all.
Now the rant is over....
a few questions...
1) why do you need the mask in the structure? If you are adding text and an image everytime the mask will be constant.
2) why do you need to know if it has children? I think you need to know if it has a parent
3) why not use CString and not char strNodeText[20]? to be really picky why is it called strNodeText? text would be fine. The node part is implied by the fact its a member of a class or struct that represents a node. The data type is implied by the word text so str is not required (i really hate hungarian notation)
4) tTreeNodeEnum.... what is this? I suspect its not required.
Why dont you have something like this
UINT id;
UINT parentId;
UINT iconResourceID;
CString text;
UINT order;
where id is just a unique number that you assign. This allows you to represent your tree structure in your data.
You could store this data in an xml file and the parentId would not be required as the tree structure would be represented by the xml. Same with the registry
Hope this helps
|
|
|
|
|
mavrick23 wrote:
Is there some way to generalize this
XML works great as a data source for tree controls.
But, that's just my opinion... I could be wrong.
Hate is not a family value.
-pete
|
|
|
|
|
i have created a status bar in my dialog based application.
the code is below:-
#define IDC_STATUSBAR 32000 //resource id
CStatusBarCtrl m_StatBar;
BOOL m_bStatOK = m_bStatBar.Create(WS_CHILD | WS_BORDER | WS_VISIBLE, rect, this, IDC_STATUSBAR);
m_StatBar.SetText("Application Running",0,0);
The program is running fine. the text is shoen on the left hand side of the status bar. Now i want to display another text on the right hand side of the statusbar. how do i do? i tried by inserting the statement
m_StatBar.SetText("Time",255,0);
But it had no impact?
how do i proceed
|
|
|
|
|
You have to first define your panes.
You will need 3 panes, one for the text on the left, one for the text on the right and one to act as a seperator.
Call CStatusBar::SetIndicators() to define the number of panes and the id for each
Then call CStatusBar::SetPaneInfo() for the seperator and give it the SBPS_STRETCH style. This will cause the seperator to fill all the unused space between the panes
|
|
|
|
|
im using mySQL and i have a problem on how to call BLOB into visual C++/MFC..the syntax and any declaration needed..
|
|
|
|
|
Hi..Check out..codeproject site..
A aritcle is there for saving BLOB data..use that method..that is applicable to all database...
Bye..Have fun..
Never consider anything Impossible before trying to solve that..---Sumit Kapoor---
|
|
|
|