|
It appears you want to send a pointer to a CString.
Wrong:
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM &) text);
Right:
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM) &text);
Personly I recommend sending the address of the string instead of the address of a CString object.
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM)(LPCSTR)text);
Trust in the code Luke. Yea right!
|
|
|
|
|
Is it possible for someone to post me a proper visual C++ intergrated with Hp Openview?
I appreciate any help. Thank you.
|
|
|
|
|
I have one Proxy Display driver. I want to debug into it. How I will able to do that ?
|
|
|
|
|
Hi,
I am using LIBXML from www.xmlsoft.org[^].
To supprt our application for Japanese platform, we are encoding the strings to UTF-8 and then putting it into XML. We were using unicode build for that. So by default the strings were 'WideChars'. But in non unicode build the strings are 1 byte char strings.
My question is how do i encode the 1 byte char strings to uUTF-8 ??
I was using MultiByteToWideChar / Widechatto ... for encoding. But in this case how do i go @ it ??
My understanding on support of internationlization is not so strong. Any focus on concepts / ideas / solution to above problems will be of great help.
thanks and regards.
|
|
|
|
|
Hi, everyone!
I want to write a simple tool to analyze the log file
of IIS. I want to make a statistical report of the site.
For example, top 20 URLs of the site which is most popular.
Better with graphics.
I want to know whether there are already some free tools
already, better with source codes.
Thanks in advance,
George
|
|
|
|
|
How to enable a menu item dynamically. I have tried EnableMenuItem but with no success.
|
|
|
|
|
Use a flag, when you press a button on a dialog or something, set your flag to TRUE and in WM_INITMENU you check whether your flag is TRUE or FALSE and then use EnableMenuItem() to disable/enable/etc your item.
Is everything clear?
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Thanks for your help. I used EnableMenuItem(0with an if statement and it worked.
|
|
|
|
|
You could use the ON_UPDATE_COMMAND_UI messages for your menu IDs if you're using MFC.
|
|
|
|
|
|
An application must use the MF_BYPOSITION flag to specify the correct menu handle. If the menu handle to the menu bar is specified, the top-level menu item (an item in the menu bar) is affected. To set the state of an item in a drop-down menu or submenu by position, an application must specify the handle to the drop-down menu or submenu.
When an application specifies the MF_BYCOMMAND flag, Windows checks all items that open submenus in the menu identified by the specified menu handle. Therefore, unless duplicate menu items are present, specifying the menu handle to the menu bar is sufficient.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Sorry but I forgot to mention that I got that from the API reference so you can refer to that for more information. I have used this function before, and I never had a problem with it.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I didn't realize that you were asking about MFC. My approach won't work with MFC. Sorry about that.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I want to get the word user typed and read it with SAPI.
The code as follow:
<br />
#pragma data_seg("shared")<br />
HHOOK m_hHook=NULL;<br />
ISpVoice * pVoice = NULL;<br />
HRESULT hr =NULL;<br />
#pragma data_seg()<br />
#pragma comment(linker,"/section:shared,rws")<br />
HINSTANCE glhInstance=NULL;<br />
<br />
.................<br />
BOOL CHookKBDApp::InitInstance() <br />
{<br />
glhInstance=::AfxGetInstanceHandle();<br />
if (FAILED(CoInitialize(NULL)))<br />
{<br />
AfxMessageBox("Error to intiliaze COM");<br />
return FALSE; <br />
}<br />
return CWinApp::InitInstance();<br />
}<br />
..............<br />
StartHook()<br />
{<br />
...<br />
m_hHook=::SetWindowsHookEx(WH_CALLWNDPROC,CallWndProc,glhInstance,0);<br />
......<br />
<br />
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam )<br />
{<br />
if( SUCCEEDED( hr ) )<br />
{<br />
hr = pVoice->Speak(test.AllocSysString(),SPF_DEFAULT,NULL); <br />
}<br />
}<br />
<br />
I don'y know where the bug is ,please someone tell me it!
thanks a lot!
Don't look at me in that way!
|
|
|
|
|
Hi!
I met some questions when I am doing some serial communication recently. I will appreciate it very much if anyone can give me tips or suggestions. And my question is described as follow:
When I communicate with another computer thru Null-cable with COM port, I found when my reading buffer is not big enough to contain the incoming data, certainly I cannot dispose the packet correctly. But when I give a bigger buffer, the seperate incoming packets will be merged in the incoming buffer. (I implement this by ReadFile(hComport, pReadBuf, nReadBufLen, &nRealBufLen, &osRead);). Is there any method to process the flow control? BTW, to manipulate RTS/CTS/DTR/DSR when there is no modem, does it have effect on the hardware/communication?
Thanks again!
|
|
|
|
|
I am not sure what the problem is but I'll try to make some sugestions.
If you are not currently using flow control (on transmit end) then you could use GetCommState(), to get the current DCB state and modify it, and then use SetCommState(). You may also need to use SetCommTimeouts() to set the time-out pramenters. (Search MSDN for examples of using GetCommState(), SetCommState(), and SetCommTimeouts())
If you know the size of the packets before they arrive you could use ClearCommError() to find out if there are at lease that many bytes in the InQue before you read out a packet size number of bytes. (or keep reading, and coping, until you receive packet size bytes)
If you do not know the packet sizes before hand then each packet needs to start with a header(record/struct) that gives you information on the packet, such as the number of bytes following the header and possibly a checksum for the packet, to insure the packet is not corrupt. For PC to PC transfer via comport the checksum is usualy not needed, but better safe than sorry.
There are some aticles on this sight that may be of some help (Search for "Serial port"). There are also some samples in the MSDN Library.
Trust in the code Luke. Yea right!
|
|
|
|
|
I'm writing a bucket hashTable template:
template<class Key, class Data, class HashFunc, class KeyEqualFunc>
class Hash
{
public:
typedef Key key_type;
typedef Data data_type;
typedef List< pair<key_type, data_type> >::iterator listIter ;
...
listIter find(const key_type& key) const;
..
private:
...
.
};
When implementing the find method, I cannot use listIter:
template<class Key, class Data, class HashFunc, class KeyEqualFunc>
listIter CsHash<Key, Data, HashFunc, KeyEqualFunc>::find(const key_type& key) const {....}
Instead I have to write this long declaration:
template<class Key, class Data, class HashFunc, class KeyEqualFunc>
CsHash<Key, Data, HashFunc, KeyEqualFunc>::listIter CsHash<Key, Data, HashFunc, KeyEqualFunc>::find(const key_type& key) const
{....}
Any suggestions how to make it shorter (and readable)?
|
|
|
|
|
If you're willing to live with #defines, I guess you could do something like this:
#define Template_CsHash template<class Key, class Data, class HashFunc, class KeyEqualFunc>
#define CsHash_T CsHash<Key, Data, HashFunc, KeyEqualFunc>
which allows this:
Template_CsHash
CsHash_T::listIter CsHash_T::find(const key_type& key) const
{....}
|
|
|
|
|
I did not know you could use typedef with in a class, it seems totaly ilogical to me. I would move the typedefs out side of the class if possible.
I suggest you look at the STL (standard template libraray) hash template, may be it will help.
Hey I am an expert on C not C++ (who is), even with 8 years of experiance in C++ (mosly MFC).
|
|
|
|
|
Does anybody knows how to open a txt file and display the results in a Listbox or edit box. The txt file contains 6 to 8 lines.
Any help will be greatly ppreciated
|
|
|
|
|
1. Take a look at CFile and CArchive in order to easily read the contents of the file.
2. ListBox: Create a var for the ListBox using the class wizard (Ctrl + W) and use Listbox.AddString this should do the thing.
3. EditBox: Create a var for the editctrl it can be a CString and then you can use that CString to modify the content of the control; read about UpdateData(); if you want, you can also declare a var of type CEditCtrl (control type in the class wizard) and then use controlvar.SetWindowText("...)...
Hope this helps...
|
|
|
|
|
Hi. I have a CMapWordToPtr object, the pointers in the CMap point to CStringArray.
The problem is, when i want to empty the cmap i don't free the memory. By MS documentation CStringArray::RemoveAt or RemoveALL should be enough, but it doesn't seem to work:
--------------------------
CMapWordToPtr *MyMap
...blablabla...
int size,i;
word key:
CStringArray *MyArray;
void *temp;
POSITION p=MyMap->GetStartPosition();
while(p){
MyMap->GetNextAssoc(p,key,temp);
MyArray= (CStringArray) temp;
size=MyArray->GetSize();
for(i=0;i<size;i++){
myarray-="">RemoveAt(0);
MyArray->FreeExtra();
}
}
MyMap->RemoveAll();
...blablabla
--------------------------
It's a major memory leak, I've tried a lot of ways and only managed to bang my head to the wall.
|
|
|
|
|
RemoveAll doesn't delete what the pointer points to. You need to go through and call "delete" on everything you called "new" on.
|
|
|
|
|
Heyas all,
Newbie Windows programmer here, I'm attempting to run an external batch file from within my console app like so:
ShellExecute(NULL, "open", "s:\\dir\\file.bat",NULL, NULL, SW_SHOWNORMAL);
The program works perfectly testing it locally, but when I run it on the target machine, the program runs but fails to run the specified batch file. s:\ is a mapped network drive.
Anyone have an info that may help me? Anything is greatly appreciated.
Thanks!
Digital Khaos
"Diplomacy is dead. Feel my wrath!"
|
|
|
|
|
Try to use WinExec( filename, SW_SHOW ) [check the parameters]. It's easier to use this until you learn how to use ShellExecute.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|