|
CString is based on TCHAR that is #define -ed as char or wchar_t depending if ANSI or unicode.
std::string is ANSI, std::wstring is unicode.
They are typedef -s for std::basic_string<char> and std::basic_string<wchar_t> respectively.
It can be probably intresting -to reproduce TCHAR adaption- to use something like
namespace std {
typedef basic_string<TCHAR> tstring;
}
and then, use
std::tstring<code><br />
<br />
<br />
<small><br />
2 bugs found.<br />
> recompile ...<br />
65534 bugs found.<br />
:doh:<br />
</small>
|
|
|
|
|
Hi all,
Now I've got a working solution...
Thanks for all your help!!!!!
Patrik
|
|
|
|
|
Anyone knows how to create, having an array of files, a HDROP object in C?
All the documentation points to COM paradigm but no documentation available under MSDN for implementing this in C.
Thank you all
Marco
|
|
|
|
|
First call DragAcceptFiles to activate D&D messages to your window.
Then respond to WM_DROPFILES - wParam has the HDROP
Call DragQueryFile and/or DragQueryPoint to obtain file names.
Then call DragFinish when you are done with the memory that the HDROP references.
|
|
|
|
|
Ok, thank you. Now my application accepts dragged files, but can't still create my own objects to drop to the shell and/or to other applications.
The only remaining question is now <<ho to="" creating="" a="" sinthetic="" hdrop="" object="" by="" choosing="" your="" own="" files="" append="" into="" clipboard?="">>
I mean, if my app had to create its own file, by "FileWriting" a stream, at the end of the ops, how it would set a synthesized object into Global Memory such to be accessed by other apps?
Is it just the same as copying a DIB or a WAVE, allocating global memory, locking and writing first some structure signature like BITMAPINFO and then the whole buffer containing zero terminated strings?
Thank you,
Marco
|
|
|
|
|
The ClipBoard is different from HDROP.
Data in the clipboard is in one (or more) of several standard formats or else in a proprietary format of your own choosing. I do believe you need to allocate memory specially for object data placed into the clipboard.
For Drag and Drop support of your own objects, you need to use COM - read about the IDropSource and IDropTarget interfaces.
The IDropSource interface is one of the interfaces you implement to provide drag-and-drop operations in your application. It contains methods used in any application used as a data source in a drag-and-drop operation. The IDropTarget interface is one of the interfaces you implement to provide drag-and-drop operations in your application. It contains methods used in any application that can be a target for data during a drag-and-drop operation.
|
|
|
|
|
Hi All,
I am launching an exe using CreatProcess. I have handle and ID of launched process and its main thread. I want the handle to its main window. How do I?
One way is through EnumThreadWindows(), which will get me all window handles for the main thread. But how do I know which one is the main window handle?
Any other aproach?
--------------
Vaibhav...
|
|
|
|
|
Hie,
The term "Main Window" is a bit confusing.I think u should think in terms of main parent window or the window whose parent is either NULL or desktop.I think there is no way to detect it thr enumwindows. Better u should check for caption of window or might be windwos style...or desktop as parent or NULL parent...
vvs
|
|
|
|
|
Use EnumWindows first to iterate through all top level windows and then use GetWindowThreadProcessId() to find the windows that belongs to process.
Regards
Abhi Lahare
|
|
|
|
|
Generally, the top level window of the app is the one without any parent, or its parent is the desktop.
Or has has been mentioned, call EnumDesktopWindows and use GetWindowThreadProcessId until you find one (or more) windows matching the process and thread id you already have.
|
|
|
|
|
Thanks Miller! I could not reply as it was weekend for me.
The solution given by you works fine and gives me the hadle.
One more thing. EnumThreadWindows() enumberates the all windows associated with a thread and returns their handles. I have noticed that the very first handle it returns is the handle of the main window. Which is exactly the same you get by your solution. So this is another approach.
I have one more query..
I am currently creating an application which requires to launch an application in backgroud and the user should not be able to see the application window. I am using CreateProcess API to launch the application in background and using the STARTUP_INFO structures's flag (STARTF_USESHOWWINDOW)to hide the newly launched application's window. But by doing this though the application is launched in background and is not visible to the end user the splash screen of the application is visible to the end user. I have tried manipulating few flags of STARTUP_INFO structure but it didnt helped.
I am looking for any alternative way by which i can accomplish the afore said task or any usefull information?
My coulleague has posted this question at following URL.
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=1022368&tid=1022368#xx1022368xx
Please respond there.
Thanks for your reply.
--------------
Vaibhav...
|
|
|
|
|
Hello,
Is it possible to prevent font scale whiel scaling metafile? I get metafile of size (x, y) and I'm rescaling it to size (2x, 2y). How can I rescale objects in metafile and leave the same size of fonts?
Thanx in advance
marukas
|
|
|
|
|
I have two questions:
1. Anyone know how to use VC++ to create and place a connection in Network Connections in Windows XP? For example, a dial up connection.
2. I want to create a connection using EAP 802.1x to authenticate to another computer. What should I do?
Thank you very much for your attention.
|
|
|
|
|
My CRecordSet derived class is corrupting the heap when MoveNext() function is called. But only for certain tables. ie, _heapchk() function asserts if called after CRecordset::Move(Rows,Type). Did anyone else faced any similar problem ?
2. How can I view all the records in a CRecordSet object while debugging. Any tips ?
p.s. I found some more information on this bug. The error happens only if any column is of type varchar and has lenght 255. If i reduce that length to 25, the error disappeared.
btw my application is unicode build.
Thanks in advance.
|
|
|
|
|
When MoveNext() is called, the columns of the current row are transferred to variables (via RFX) in the record set. Are the variables of sufficient size? This is just a guess.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes , i can understand friend...but this case works out in a single machine..But in Client and Server concept it fails..I use the same GetKeyState() fn to retrieve the keystate...I check for its return value...
getKey = ::GetKeyState(vk);
if(getKey & 0xF000)
printf("%c pressed 0xF000\n",tempbuffer[c]);
else if(getKey & 0x000F)
printf("%c releases 0x000F\n",tempbuffer[c]);
else if(getKey & 0x0001 == 0x0001)
printf("%c Key is toggled\n",tempbuffer[c]);
else if( getKey & 0x8000 == 0x8000)
printf("%c Key is pressed\n",tempbuffer[c]);
else
printf("%c key is neither pressed nor toggled",tempbufferc]);
}
For the above cases
for some of the characters condn. fails and so the message
"Key is neither pressed nor toggled " message gets printed.
What can i do for this ?
Thank u
|
|
|
|
|
What
Like, if you ask for a key and it is NOT pressed or not recently released, why wouldn't you expect to see 'neither pressed nor toggled'.
You did not mention this is in response to a WM_CHAR or other message where you would EXPECT it to be one of those values.
If I just randomly query virtual keys (or any specific key, but randomly query its state) then of course I would expect that sometimes it has 'no state' at all.
|
|
|
|
|
I defined a volume "z:" use DefineDosDevice(),and i want to let the explorer windows currently accessing volume "z:" close atomatically when i undefine z:.How can i achieve this?
|
|
|
|
|
I wrote a class CClientSocket for async-sockets communication, and a class CSockWnd to receive socket event notifications. But when a CClientSocket object works, CSockWnd cannot receive any notifications. I'm sure that CClientSocket can send/receive data, and "SendMessage((HWND)(*CSockWnd::GetInstance()), WM_CLIENTSOCKET, m_hSocket, FD_CONNECT);" can work. But CSockWnd cannot receive notifications from system when net events coming.
Some codes here:
/* Create a socket, and call WSAAsyncSelect. */
// Create a local socket
m_hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if(m_hSocket == INVALID_SOCKET)
{
m_strLastError = TEXT("CClientSocket::Connect::socket failed.");
ReportError(ERROR_LEVEL_INFORMATION, m_strLastError.c_str());
return FALSE;
}
// singleton, attach this to CSockWnd; and CSockWnd can callback this when net events coming.
CSockWnd::GetInstance()->Attach(this);
// call WSAAsyncSelect
if(WSAAsyncSelect(m_hSocket, (HWND)(*CSockWnd::GetInstance()), WM_CLIENTSOCKET, FD_READ | FD_CLOSE | FD_CONNECT))
{
m_strLastError = TEXT("CClientSocket::Connect::WSAAsycSelect failed.");
ReportError(ERROR_LEVEL_INFORMATION, m_strLastError.c_str());
return FALSE;
}
In addition, all classes work in a win32 DLL.
|
|
|
|
|
Hello,
Can you tell me know ? May I use ADO with RecordBinding and without RecordBinding ?
What is RecordBinding ?
Thank you.
|
|
|
|
|
If I want to detect the activity(Playing or Recording) of audio device, how can I do?
Is there any Windows API function, Service, or Driver solution?
In addition, how to detect the activity of devices like bluetooth, wireless...etc
Jesa
|
|
|
|
|
I've been creating a simple Win32 (not MFC) program, with a List Box Control (with images and a Image List), but when I try to read the selection get 0, or when I should receive a LBS_SELCHANGE notify message, I receive a WM_NOTIFY->LBN_ERRSPACE error:
"An application sends the LBN_ERRSPACE notification message when a list box cannot allocate enough memory to meet a specific request. The parent window of the list box receives this notification message through the WM_COMMAND message."
This solves nothing at all. The RC:
CONTROL "List1",IDC_LAPP,"SysListView32",LVS_LIST |
LVS_SINGLESEL | LBS_STANDARD | WS_TABSTOP,63,7,158,204,
WS_EX_CLIENTEDGE
The code:
Item = GetDlgItem(hWnd, IDC_LAPP);<br />
...<br />
ImageList = ImageList_Create(IconSize, IconSize, ILC_COLORDDB, 0, 0);<br />
...<br />
SendMessage(Item, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ImageList);<br />
...<br />
memset(&LVI, 0, sizeof(LVITEM));<br />
LVI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_NORECOMPUTE | LVIF_DI_SETITEM;<br />
LVI.iItem = 0;<br />
LVI.iSubItem = 0;<br />
LVI.pszText = Disco.Base->Name;<br />
LVI.cchTextMax = sizeof(Disco.Base->Name);<br />
LVI.iImage = 0;<br />
LVI.lParam = NULL;<br />
LVI.iIndent = 0;<br />
LVI.stateMask = LVIS_SELECTED;<br />
SendMessage(Item, LVM_INSERTITEM, 0, (LPARAM)&LVI);<br />
<br />
LVI.pszText = "Mazonza2";<br />
LVI.iImage = 1;<br />
SendMessage(Item, LVM_INSERTITEM, 0, (LPARAM)&LVI);<br />
<br />
case WM_NOTIFY:<br />
if(wParam == IDC_LAPP)<br />
{<br />
pnmh = (LPNMHDR) lParam;<br />
if((pnmh->code == LBN_ERRSPACE) || (pnmh->code == LBN_SELCHANGE))<br />
{<br />
Sel = SendMessage(Item, LB_GETCURSEL, 0, 0);<br />
if(Sel != LB_ERR)<br />
{<br />
sprintf(S, "%i - %s", Sel, (pnmh->code==LBN_ERRSPACE ? "LBN_ERRSPACE" : "LBN_SELCHANGE"));<br />
MessageBox(NULL, S, "WM_NOTIFY", MB_OK);<br />
}<br />
}<br />
}<br />
break;<br />
<br />
<br />
What am I doing wrong? Memory from where? No memory problems on the system at all, everything is controllated, so may be the code.
Thanks.
Alfonso Vila
"If the program works at first, maybe you're in an exam"
|
|
|
|
|
You're confusing the list box control (class ListBox ) and the list view control (class SysListView32 ). LBN_SELCHANGE , LBN_ERRSPACE , LB_GETCURSEL ... these are all relevant to the ListBox only. You'll be wanting to use LVN_ITEMCHANGED , LVM_FINDITEM and/or LVM_GETSELECTIONMARK instead.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...
|
|
|
|
|
at the point of frustration about a little thing, i'll ask this:
why doesn't my right-click menu go away?
i have no problem putting an icon in the system tray, nor receiving mouse notifications. Then i use TrackPopupMenu after receiving a right button up to bring up a popup menu. Then why would that menu not go away when i click away from the menu (i.e. on another window)!!?
forgive the stupidity & resulting frustration.
|
|
|
|
|
See the Remarks section of the TrackPopupMenu function reference on the MSDN site. Basically, your window must be the foreground window before the call to TrackPopupMenu, or you can just do the following after you call TrackPopupMenu:
PostMessage(hWnd, WM_NULL, 0, 0);
|
|
|
|
|