|
Hiii,
I cannot use SetCommState as I don't want to set the baud rate of the port.
I don't want to use RS-232 protocol.
I think it can be done using _inp() n _outp() functions but don't know how. Help required.....
Plzzzzzzzzzzzzzz send reply as soon as possible.
Thanks in advance.
|
|
|
|
|
Hello all,
I'm having difficulties to get the string of a menu item pressed.
What I'm doing is writing a IE toolbar and in one of the pull down menu's I dynamically add popup menu's which are also dynamically filled.
Just for a theoretical example let's say I have a button 'drives' on the toolbar. Pressing the pulldown menu will add some menu entries (the same amount of disk on my system, C; D; E; ...).
Every menu item is a popup itself, and a dynamically created Popupmenu is attached - containing the root level directories for the selected drive (temp, program files, winnt, ...).
Following is an adapted piece of code, but it works how it suppose to
<br />
MENUITEMINFO mmi;<br />
mmi.cbSize=sizeof(MENUITEMINFO);<br />
mmi.fMask=MIIM_STRING | MIIM_DATA | MIIM_SUBMENU;<br />
<br />
char fn[50];<br />
<br />
for (int i=0; i<3; i++)<br />
{<br />
HMENU hMenuToInsert;<br />
hMenuToInsert = CreatePopupMenu();<br />
{<br />
char drv[255];<br />
while (getthedrives)<br />
{<br />
sprintf( drv, "%s", a_directory);<br />
AppendMenu(hMenuToInsert, MF_ENABLED|MF_STRING, ID_DUMMY, drv);<br />
}<br />
}<br />
sprintf( fn, "Drive %s", drvletter);<br />
mmi.hSubMenu = hMenuToInsert;<br />
mmi.dwTypeData = fn;<br />
mmi.fType=MFT_STRING;<br />
InsertMenuItem(m_hDriveMenu, 2+i, TRUE, &mmi);<br />
<br />
}<br />
The problem I'm having is, is that I'm using a dummy ID (ID_DUMMY).
When my ON_COMMAND fires, I have no way to get the correct menu item using GetMenuItemInfo because
a) I'm using the same id for every popup menuitem inserted
b) I'm reusing the HMENU (hMenuToInsert) for my popmenu's
Does anyone know of a simple way to get the text of the menu (directorys on a drive in my case) pressed?
Thanks
Wim
|
|
|
|
|
|
Hi Michael,
I'm reusing them because I really have no clue how many directories I will have.
Let's say I have 10.000 directories, that means I have to define 10.000 unique id's. You know of a way to create that many on the fly, or maybe a better way to do it?
The other problem I have then is to what popupmenu the directory I clicked belongs (C:, D:, E , but I supppose I can have a list of HMENU id's and I check every list/MENU_ID for success.
Thanks
Wim
|
|
|
|
|
Well, command IDs can be in the range 1-65535. Just start a counter a 1 and increment it for every menu item you add. Each menu under the first level can use 1-65535, you don't need a unique ID for every single item if you think you'd ever have more than 65535. You can tell which top-level popup has been selected by handling WM_MENUSELECT , and from there you can work out which directory was selected.
You should also give the top-level popups IDs for easier tracking (and those IDs shouldn't be duplicated in the submenus). You can do this with InsertMenuItem() .
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0.1! | RightClick-Encrypt
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
Ok,
I see it now. One thing what I discovered when playing with the WM_MENUSELECT was that I couldn't get the (a random) text from my popup menu (just for a test, take the first entry of the popupmenu, I will move it to the WM_COMMAND later).
What I did was this:
<br />
LRESULT CMyToolBar::OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
if (lParam&&(HIWORD(wParam)&MF_POPUP))<br />
{<br />
HMENU hSubMenu = GetSubMenu ( (HMENU)lParam, LOWORD(wParam));<br />
<br />
MENUITEMINFO mii;<br />
mii.fMask = MIIM_STRING;<br />
<br />
char c[2000];<br />
mii.dwTypeData=c;<br />
mii.cch=2000;<br />
<br />
GetMenuItemInfo(hSubMenu, 0, TRUE, &mii);<br />
MessageBox(mii.dwTypeData);<br />
}<br />
return 0;<br />
}<br />
According to the documentation, lParam contains the Handle to the menu I pressed (the main menu), and if HIWORD(wParam) contains flag MF_POPUP, the LOWORD(wParam) contains the the position pressed in the menu.
If I use GetSubMenu((HMENU)lParam, HIWORD(wParam)), I should get the handle to my popupmenu containing the directories, right?
I outputted the parameters, and the handle and index looked OK.
But when I used GetMenuItemInfo using the handle obtained with GetSubMenu and index 0 (the first Item in the popup menu), it returns an empty string.
Any idea what I'm doing wrong?
Thanks
Wim
|
|
|
|
|
Michael,
Just wanted to thank you again for your excellent answer. Got it working now.
Regards
Wim
|
|
|
|
|
If one has an app with a tray icon and menu, is there a way to create a graphic to the left side of the popup menu? It would run the complete vertical length of the menu.
Best Wishes,
ez_way
|
|
|
|
|
|
Hi, I wrote an application which connects via an HTTP proxy. Can I get the default proxy from the system (hostname and port)? Alternatively can I get it from IE?
|
|
|
|
|
Hi,
There is not such a thing as the system proxy. WinINet functions are tied to IE, and it is IE settings that you can get and set with this library. Take a look at InternetQueryOption documentation.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Cheers, I'll try... following what I have found
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/internetqueryoption.asp
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q226/4/73.asp&NoWebContent=1
|
|
|
|
|
Hi!
I need to convert a TCHAR* string (which actually can be a char* or wchar_t* string) to UTF-8 format and the other way round.
I cannot use the MultiByteToWideChar and WideCharToMultiByte functions.
Is there a small, tiny library that does this? I've had a look at IBM's ICU, but this library does much too much, I don't need all those additional conversion functions, etc.
Or is there perhaps a simple method how I can do the conversion myself?
Thanks in advance!
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I dunno how allergic you are to the LGPL license, but here's one library which can do the transformation for you: http://www.gnu.org/software/libiconv/[^]
--
Seraphim Shock. Gold for your ears.
|
|
|
|
|
Hey all.
I have read a couple of articles on this site (and others) that I thought would help out, but was not exactly what I was looking for.
I have modified the default "MFC" icon in my app to put my own in there. I compile and run it, all is fine, it shows up correctly.
However, when I am looking at files with Explorer, the file shows up with the MFC icon! It shows up with the MFC icon, then the program name, and then "TODO: <file description="">" ... I figured out where I put in the description, company name and all that good stuff, but I can not figure out how to make it use the icon that I created that gets displayed on the taskbar when the program runs. Any suggestions?
Thanks
|
|
|
|
|
the icons have different sizes for different display contexts
make sure u edit the 16x16 icon too
"there is no spoon" biz stuff about me
|
|
|
|
|
If I open up my project , under "Icon" there is only one. IDR_MAINFRAME and under appearance it says "32x32". I've looked all through the resources and do not have a 16x16 or any other icon in there.
Do I have to add a new ICON and make it 16x16? If so, how would I then tell the program to use it?
Thank You
|
|
|
|
|
|
I'm using VS .NET now, but I did find the place where the multiple sizes are.
Man alive, there are 9 of them! Different sizes and colors!
So I pretty much have to edit all of them, right?
It says like 16x16, 16 colors, 16x16 256 colors, 16x16 16million colors (or something like that)
So is that so depending on what the users computer display color depth is set at which icon will be displayed?
Thanks!
|
|
|
|
|
yup u got it
altho a 16color and a 256 color will generally be ok
in fact i only use 16color for the small ones
"there is no spoon" biz stuff about me
|
|
|
|
|
THANKS!!!
It works perfectly now!
Took me a bit to figure out the Icon Editor!
|
|
|
|
|
Is anybody can help me,if i want use three radio button to control the motor run in different speed.......what is the source i need to add!!!!!!!!!!
|
|
|
|
|
write an onclick() handler for the radio buttons and do ur logic there
"there is no spoon" biz stuff about me
|
|
|
|
|
Can u explain more detail how i use the logic to control motor run in different speed.....
|
|
|
|
|
What kind of motor is it? What are you using as a hardware controller? Did it come with a driver package? Is there an API for programming it? The method Lauren describes is simple enough, but we're working in the dark here. If you haven't got some kind of specific controller in mind, find one and provide some details. Nothing on your PC can directly control a motor (other than perhaps a single-speed dc motor connected to a line on a parallel port). For a dc motor you'll need at a minimum a D/A converter with a power amp. You'll probably also want an A/D converter with a tachometer on the motor for feedback, if the speed has to be regulated under load. For a stepper motor you'll need a stepper controller card, and you'll program it for a selectable step rate. A synchronous motor will need a programmable ac power supply to control it properly by varying the frequency. What are you using?
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|