|
You could use a union:
union my_union_t
{
struct
{
char[30] name;
int salary;
float age;
}
struct
{
double a[100];
float b;
long c[200];
int d;
char e;
}
};
you'd have to fill the union with all possible configurations, so it's not really at run time, but I'm not really sure that's possible.
|
|
|
|
|
The path goes to Project->Settings->Debug->Program arguments.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
I want to display the text of the previous selected tree-item.
I handle the tvn_selchanging message:
OnSelchangedTreeview(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
TV_ITEM tvItem;
tvItem = pNMTreeView->itemOld;
AfxMessageBox(tvItem.pszText);
*pResult = 0;
}
But this does not work, gives me all kinds of weird characters.
Anyone knows what the problem might be?
Greetings
Jens
|
|
|
|
|
I don't believe itemOld is valid at that point. You could just store the text in a member variable everytime a selection is made.
OnSelchangedTreeview(NMHDR* pNMHDR, LRESULT* pResult)
{
AfxMessageBox(m_strOldSel); // show old one
m_strOldSel = pNMTreeView->itemNew.pszText; // set it for next time
}
|
|
|
|
|
In my Application I got a lot of options that the user can customize the application with.
The problem I got is that when the option dialog is close I need to tell ALL windows that options have been changed so they can re-read them.
So is there a way to send a message that is received by ALL windows??
/Mathias
|
|
|
|
|
Yes, but make sure that ALL windows care about what is going to be sent to them before blindly sending a "global" message.
SendMessage(HWND_BROADCAST, ...);
|
|
|
|
|
Hi all,
does anybody know what the exact syntax is for sending a CString variable with SendMessage? I have tried every thing you can imagine:
UINT MyThread(LPVOID arg)
{
HWND hMain = (HWND) arg;
CString text;
text = "Hello";
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM &) text);
}
LRESULT CMyDlg::OnSendHello(WPARAM wParam, LPARAM lParam)
{
CString* text = (CString *) lParam;
return 0;
}
What is wrong with this code?
|
|
|
|
|
Try correcting your SendMessage to this:
SendMessage(hMain, WM_SEND_HELLO, 0, (LPARAM) &text);
Maybe you need a LPCTSTR cast for &text, if it doesn't compile.
|
|
|
|
|
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)?
|
|
|
|
|