|
I want to ask you something ( maybe ) simple question :
Can I initialize an CListBox& ListCtrl reference with null value ? Because later , I want to use ListCtrl reference variable in many if contitions ...
I try :
CListBox& ListCtrl = NULL;
and doesn't go ...
Give me an error like this :
initializing' : cannot convert from 'const int' to 'class CListBox &'
|
|
|
|
|
Hi,
You are trying to initialize a reference to CListBox, in which case you need to give proper object. NULL is nothing but a typedef of '0'. To solve your problem try to use a pointer variable instead of reference variable.
CListBox *pListBox = NULL;
|
|
|
|
|
I can use CListBox* pList = NULL;
Why , because somewhere I have :
CListBox& GetListBoxCtrl() const {return *(CListBox*)this;}
How can I solve the problem ?
|
|
|
|
|
You cannot assign NULL to a reference.
In your case you can do this - CListBox* pListBox = &GetListBoxCtrl();
|
|
|
|
|
Nope.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I open an notepad application :
void CTestMessageView::OnHelpStartapplication()
{
ShellExecute(m_hWnd,"open","notepad.exe",NULL,NULL,SW_SHOWNORMAL);
}
and I want to send some message to notepad :
void CTestMessageView::OnHelpSendmessage()
{
CString sTemp = "Test message\n";
HWND hWnd = ::FindWindow("Notepad",NULL);
if(hWnd)
{
::PostMessage(hWnd,WM_CHAR,(WPARAM)'1',0);
::PostMessage(hWnd,WM_KEYDOWN,'1',0);
::PostMessage(hWnd,WM_SETTEXT,0,(LPARAM)(LPCTSTR)sTemp);
::PostMessage(hWnd,EM_REPLACESEL,0,(LPARAM)(LPCTSTR)sTemp);
}
}
but only first message WM_CLOSE ( comment one ) is receipt by notepad , other , not . I think that other message then WM_CLOSE is addressed for view of notepad , not the main frame window of the notepad . My question is , how can I send message to the view , not the main frame window of notepad ?
modified on Saturday, January 1, 2011 9:13 AM
|
|
|
|
|
Do an EnumChildWindows[^] on your hWnd and locate the edit control
Regards
Espen Harlinn
|
|
|
|
|
What exactly are you trying to do here?
Opening notepad and then sending it a WM_CLOSE does not make sense.
Notepad also takes a command line parameter if you want to open a file in it.
For eample - notepad.exe c:\windows\win.ini
|
|
|
|
|
I think he's trying to open Notepad and insert some text (the sTemp string.)
What he's found is 4 ways to insert text which do not work, and also found that sending a WM_CLOSE does work. It's a start.
|
|
|
|
|
you can't just pass pointers from one process to another process; they must be meaningful and accessible for the receiver, and in general buffers at the sender are neither to the receiver. It would take some calls to VirtualAllocEx, WriteProcessMemory, and the like to achieve such things.
But then, why would you? if you want to open Notepad on an empty document and then "type" some, why not simply create a text file first, then open it with Notepad? You wouldn't need any Win32 API function to do that.
|
|
|
|
|
hi
how can i have nested groups in a CPropertyGridCtrl without increasing indent?
let me depict what i'm going to do. i've a ready program with the following output:
original[^]
i tried to create the same output with the following code:
void AcItemPropertyPane::pr_appendLinkProp(CMFCPropertyGridProperty *pGroup, const AsLink &link)
{
CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty("Coordinate for Goto", 0, TRUE);
CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty("Address X", (_variant_t) link.col, " ");
pProp->EnableSpinControl(TRUE, 0, 99);
pGroup2->AddSubItem(pProp);
pProp = new CMFCPropertyGridProperty("Address Y", (_variant_t) link.row, " ");
pProp->EnableSpinControl(TRUE, 0, 9);
pGroup2->AddSubItem(pProp);
pGroup->AddSubItem(pGroup2);
pProp = new CMFCPropertyGridColorProperty("Color of Goto Route", (_variant_t) link.color, NULL, "Goto line color change");
pGroup->AddSubItem(pProp);
}
void AcItemPropertyPane::pr_initADSensorPropList(const AsItemSpec &is)
{
d_wndPropList.RemoveAll();
CMFCPropertyGridProperty *pGroup = new CMFCPropertyGridProperty("AD Setup");
CMFCPropertyGridProperty *pProp = new CMFCPropertyGridProperty("A/D port", " ", "A/D port setup");
pGroup->AddSubItem(pProp);
pGroup->AddSubItem(pr_newFuncProp(is.func));
pProp = new CMFCPropertyGridProperty("Compare variable/value", " ", "When jump is compare to Input value (0-255).");
pGroup->AddSubItem(pProp);
pr_appendLinkProp(pGroup, is.link);
d_wndPropList.AddProperty(pGroup);
}
(pr_initADSensorPropList is called).
but it resulted in the following output:
mine[^]
there's also a difference in the original color property and mine. also separator in coordinate differ (; with ,)
how can i make mine appear the same as the original one?
thank u
|
|
|
|
|
Index is removed from msdn by default in visual studio 2010. Although there are some plugin, but not as good as in VS2008.
BTW, when opening and running two or more instances of VS2008, the UI will be out of order. For example,
running a server and a client in two instances of VS2008, when one aborted, one of the UI became out of order, I don't remember which.
What's like, the index in mysql document is also removed.
============
If search works, it is also possible to build an index only once instead?
I think M$ is collecting in the search procedure for analysis, for its bing.com.
modified on Sunday, January 2, 2011 9:47 PM
|
|
|
|
|
Is this a question about C++, or simply a rant about Microsoft?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
about its programming environment
modified on Saturday, January 1, 2011 9:57 PM
|
|
|
|
|
Hi
I have created the event using CreateEvent Method. But I am not able to open this event using ::OpenEvent () method from RTOS Application. Do I need to create the event by setting some security level in first parameter of CreateEvent ().
Thanks
|
|
|
|
|
the security parameters can be NULL. its ok. CreateEvent will the use the default level of security.
To use openevent function you must have to create a named event. Did you created event like that ?
If u can Dream... U can do it
|
|
|
|
|
Yes I have created the Named event . I have Opened this event successfully and used in another win32 process. As I am trying this with RTOS , not able to find out why my RtOpenEvent fails.
::RtOpenEvent and ::OpenEvent both are supported in my RTOS SDK. I have also tried to use Global\\MyEventName .
Thanks and happy New Year
|
|
|
|
|
I don't know about RtOpenEvent , but this is what I would do if OpenEvent fails.
I would first check its return value to find that it failed.
I would then call GetLastError to find out why the API failed.
You should have something similar for the RTOS APIs.
|
|
|
|
|
hmm, sharing events betwen processes... its been a long time since i did usermode stuff but is it even possible?
"It is a remarkable fact that despite the worldwide expenditure of perhaps US$50 billion since 1990, and the efforts of tens of thousands of scientists worldwide, no human climate signal has yet been detected that is distinct from natural variation."
Bob Carter, Research Professor of Geology, James Cook University, Townsville
|
|
|
|
|
Named kernel objects are sharable across processes.
|
|
|
|
|
I have used named kernel objects. Also I have tried to set the security attribute with following code
SECURITY_ATTRIBUTES secAttr;
char secDesc[ SECURITY_DESCRIPTOR_MIN_LENGTH ];
secAttr.nLength = sizeof(secAttr);
secAttr.bInheritHandle = FALSE;
secAttr.lpSecurityDescriptor = &secDesc;
::InitializeSecurityDescriptor (secAttr.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION);
::SetSecurityDescriptorDacl(secAttr.lpSecurityDescriptor, TRUE, 0, FALSE);
HANDLE hEvent = ::CreateEvent( &secAttr, TRUE, FALSE, L"Global\\MyEvent");
Still facing the same problem : openEvent fails to open this event
|
|
|
|
|
Did you do what Superman told you to? What is the result?
|
|
|
|
|
Result : OpenEvent in my RTOS fails , handle return is NULL , GetLastError Return 2 which is File NOT Found error as per WinError.h
|
|
|
|
|
I am sorry, I can't help you any further. The RTOS docs are your best friends. Also, consult other people who use the same RTOS.
|
|
|
|