|
Hi
I just switched from Visual C++ 6 to Visual C++ .NET and converted my old project (.dws) to a solution. Now, when I try to compile my program I get compiler errors I didn't get under VC++6:
CStringArray status;
status.Add("test");
...
cbei.pszText = status.GetAt(0).GetBuffer();
error:
error C2663: 'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::GetBuffer' : 2 overloads have no legal conversion for 'this' pointer
with
[
BaseType=char,
t_bMFCDLL=true
]
what does that mean?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
What is cbei.pszText?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
It's a COMBOBOXEXITEM struct.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Call GetBuffer(0) which will give you a non-const pointer to whatever the current contents of the string are.
--Mike--
"Big handwavy generalizations made from a position of deep ignorance is one of the biggest wastes of time on the net today.
-- Joel Spolsky
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I still get the same error. I can't understand what an error regarding 'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::GetBuffer' : 2 overloads have no legal conversion for 'this' pointer has to do in context of a simple CStringArray
modified 12-Sep-18 21:01pm.
|
|
|
|
|
How do i get a handle to the child edit window that currently has the focus (in another app)?
Kuniva
--------------------------------------------
|
|
|
|
|
GetForegroundWindow() should work for most controls.
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"
|
|
|
|
|
mm i thought that only got the parent window, but anyways, found a way around it already using keybd_event().
But now i came accross another problem: I'm trying to put text in the edit that has the focus using keybd_event() and sending the keycodes. I'm running XP and i'm doing something like this:
char* message = Hello!";
BYTE scan=0;
DWORD flags=0,info=0;
Sleep(5000); // Sleep for 5 seconds so i can switch windows and set focus to an edit
for(int i=0;i<sizeof(message);i++)
{
keybd_event((int)message[i],scan,flags,info);
}
Now the problem is that i don't get my message at all. Its like the codes shift and take on another value. So what i tried was changing the value of message[i] with a constant. I then found when i substracted 32 i got the lowercase letters to work right, but now my problem is, everything else still doesnt work! The capitals arent right and neither is anything else.. whats causing this?? I thought if u specify a char like that it gives the value from 0 to 255 and its the right ASCII code?? How do i fix this?
Many thanks
Kuniva
--------------------------------------------
|
|
|
|
|
Kuniva wrote:
I thought if u specify a char like that it gives the value from 0 to 255 and its the right ASCII code??
No. keybd_event() takes the virtual-key code of the key. On a keyboard, the lower-case and upper-case letters are produced with the same key. To produce an upper-case key, you have to simulate the shift key being pressed as well. Similarly for an exclamation mark (shift-1). Also, you'll need to simulate the keys being released as well as pressed. You'll have to do something like this:
keybd_event(VK_SHIFT, 0, 0);
keybd_event('H', 0, 0);
keybd_event('H', 0, KEYEVENTF_KEYUP);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP);
keybd_event('E', 0, 0);
keybd_event('E', 0, KEYEVENTF_KEYUP);
keybd_event('L', 0, 0);
keybd_event('L', 0, KEYEVENTF_KEYUP);
keybd_event('L', 0, 0);
keybd_event('L', 0, KEYEVENTF_KEYUP);
keybd_event('O', 0, 0);
keybd_event('O', 0, KEYEVENTF_KEYUP);
keybd_event(VK_SHIFT, 0, 0);
keybd_event('1', 0, 0);
keybd_event('1', 0, KEYEVENTF_KEYUP);
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP); Hope this helps,
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 want to use a SDI project that's derived from the CTreeView class. However, I have some code and specialty functions in a couple of classes already derived from CTreeCtrl. Is it possible to link the CTreeView in the SDI to my classes or derive it's tree control from the classes I have?
|
|
|
|
|
No. It's going to take some work. I would recommend that you look on CodeGuru as Zafir wrote some articles on doing this sort of thing a few years ago. Try the treeview section. If that doesn't work, I know he did it in the listview section. That will just mean more work in terms of figuring out how to make it work for the treeview.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Maybe it would be easier to put your CTreeCtrl-derived control on a CFormWnd derived class and have it resize the CTreeCtrl to fill the FormWnd completely?
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
How would one go about doing that?
|
|
|
|
|
A CFormView (sorry - I gave the wrong class name in the previous post) is
"essentially a view that contains controls.
These controls are laid out based on a dialog-template resource."
<small>(from the MSDN entry <code>CFormView</code>)</small>.
You insert it with the wizard into your project. Place a CTreeCtrl on it.
Now your program should compile and link and the view shows an empty tree.
If you resize the tree, it will probably fill only parts of the view or the view will show scroll bars.
In your View class, override the handler for the message WM_SIZE to resize the TreeCtrl to the entire pane. That does mean, in your OnSize()-function, you call m_TreeCtrl.MoveWnd() with the new dimensions as received as parameters.
Now the TreeCtrl should follow the resizing of your View.
As the last step you can replace the CTreeCtrl with your own derived class. That is done without wizard help, simply by find-and-replace. If you miss one CTreeCtrl, you will get all sorts of funny errors. Just go around and replace the missing CTreeCtrl-occurences in your code.
Sorry if this sounds much, but it is not. The only thing that could be tricky is the OnSize() thing. Try it, and ask here again!
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Isn't the correct function MoveWindow?
How do I get the coordinates of the window into the RECT object. I forgot how to do that!
void CSacmanEditorView::OnSize(UINT nType, int cx, int cy) <br />
{<br />
CFormView::OnSize(nType, cx, cy);<br />
RECT window;<br />
<br />
this->m_ctrlEditorTree.MoveWindow(window);<br />
}
|
|
|
|
|
For getting the coordinates of the View you use GetParent()->GetClientRect(). (The Parent should be the View-pane).
I forgot whether you have to convert that with ClientToScreen().
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hi, i need to close another applications receiving UDP socket. How would i do this? Do i need to use API hooking to hook the receive function??? or is there an easier way to close a UDP socket and stop the transfer of data??
Please help me, it is for a good purpose (an anti-crash)..
Kuniva
--------------------------------------------
|
|
|
|
|
Is it possible to make another applications TCP socket send some data as if the application sent it itself (so that for example, the sequence numbers would still be correct afterwards)?
Kuniva
--------------------------------------------
|
|
|
|
|
I don't know if an other app can do that, but a hook sure can . I don't know how to close sockets, not my field, sorry..
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
A question for the Thai programmers among us. I am after the MFC language resources that reside in the l.* directories, for building an application in Thai.
I would be most grateful if someone could point me in the right direction. I have searched the MSDN CDs we have here at work, but to no avail.
Happy programming!!
|
|
|
|
|
Just use Visual C++.NET.
Visual C++.Net (2002 or later) already support Thai Language. For Visual C++ 6.0, you need to buy a Thai version of Visual C++ 6.0 IF available I guess or probably Microsoft had provided a language pack.
To change to Thai version of RC (codepage) in Visual C++.Net. Just right click on your resource in the resource tab for eg. your dialog and change the language setting.
To learn to program your application in Thai. Just look for UNICODE string handling routines and tutorials which are available in CodeProjects.
Hope this helps.
|
|
|
|
|
Some time ago I built an application that contained English, Chinese Trad., and Chinese Simp. resources and it worked well in Chinese on the relevant insallation of Windows. I have now come across a problem that on XP it doesn't work. It is always in English, even when XP is rebooted in chinese, the keyboard is in chinese mode and SetThreadLocale is called in the InitInstance of the App.
Does anyone have any ideas on where the problem lies?
Happy programming!!
|
|
|
|
|
I am writing a dll that can open a process and place it in a job. I need to be able to change the limits of the job and\or add new ones after I have set them (I set the limits by calling SetInformationJobObject).
I have tried using QueryInformationJobObject() to fill a structure with the current limits and then add one limit to the existing structure. However, when I call "SetInformationJobObject" again, I overwrite the current limits that are set (Do I have to re-set each bit using LimitFlags everytime I want to change or add a limit)
Can I change the limits on a job after I have set them. If so, when can I do it so that it will apply to the processes that are in the job and the process that I am placing in the job, and do I have to set each restriction bit (using LimitFlags) for every restriction everytime i want to change to limits. If this explanation is hard to read, please let me know so that I can modify it...Any and all help is greatly appreciated....thanks
|
|
|
|
|
I create modelles dialog box as child inside a window
(not using MFC) tab navigation between controls does not work
is there some way to implement it ?
Thanks.
|
|
|
|
|
I had the problem with a modeless dialog owned by an ActiveX main window. Using MFC, I solved this by implementing in the PreTranslateMessage method of the Main Window the following code:
<br />
if((pMsg->message == WM_KEYDOWN) && (::IsWindow(pMsg->hwnd))){<br />
HWND hMsgWnd = pMsg->hwnd;<br />
HWND hParent = ::GetParent(hMsgWnd);<br />
<br />
if(hParent){<br />
if((pMsg->wParam == VK_TAB) || (pMsg->wParam == VK_RETURN)){<br />
if(CWnd::FromHandle(hMsgWnd)->PreTranslateMessage(pMsg))<br />
return TRUE;<br />
else <br />
if(pMsg->wParam == VK_TAB){<br />
BOOL bShift = HIBYTE(GetKeyState(VK_SHIFT));<br />
HWND hNewWnd = ::GetNextDlgTabItem(hParent, hMsgWnd, bShift);<br />
if(hNewWnd){<br />
TCHAR szClass[10];<br />
HWND hFirstWnd = hNewWnd;<br />
BOOL bBreak = FALSE;<br />
while(::GetClassName(hNewWnd, szClass, 10) && (lstrcmpi(szClass, _T("STATIC")) == 0)){<br />
HWND hOldWnd = hNewWnd;<br />
hNewWnd = ::GetNextDlgTabItem(hParent, hNewWnd, bShift);<br />
if(hNewWnd == hOldWnd){<br />
hNewWnd = NULL;<br />
break;<br />
}<br />
if(bBreak){ <br />
hNewWnd = NULL;<br />
break;<br />
}<br />
bBreak = (hNewWnd == hFirstWnd);<br />
}<br />
if(hNewWnd){<br />
::SetFocus(hNewWnd);<br />
return TRUE;<br />
}<br />
}<br />
}else{<br />
if(pMsg->wParam == VK_RETURN){<br />
TCHAR szClass[10];<br />
<br />
if(::GetClassName(hMsgWnd, szClass, 10) && (lstrcmpi(szClass, _T("BUTTON")) == 0)){<br />
::SendMessage(hParent, WM_COMMAND, ::GetDlgCtrlID(hMsgWnd), (LPARAM)hMsgWnd);<br />
return TRUE;<br />
}<br />
}<br />
}<br />
<br />
return CWnd::FromHandle(hParent)->PreTranslateMessage(pMsg);<br />
}<br />
if(CWnd::FromHandle(hParent)->PreTranslateMessage(pMsg))<br />
return TRUE;<br />
}<br />
}<br />
We do not inherit the Earth from our ancestors, we borrow it from our children - Antoine de Saint-Exupéry (1900-1944)
|
|
|
|
|