|
You can call CMenu::GetMenuItemInfo[^] Please follow the link, it describes how to use the API
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Dear Friends,
Please could you give an idea about below question.
need difference between using static variable in 'C' and 'C++'.
Thanks,
Sakthi
Nice things do nice works
|
|
|
|
|
|
i m creating 3 queutimers and after adding them in queue using 3 callbacks functions for each timer ,and calling one function after 10ms 2nd func after 100 ms,3rd func after 1sec but its not working properly they functions are not executing at specefied intervals,to call them after a bit interval i hv to use sleep method . so plz tell me how to fix it the code is below
HMODULE hlib = LoadLibrary ("kernel32.dll");
CTQ CreateTimerQueue = (CTQ)GetProcAddress (hlib, "CreateTimerQueue");
CTQT CreateTimerQueueTimer = (CTQT)GetProcAddress (hlib, "CreateTimerQueueTimer");
HANDLE htimer=CreateTimerQueue();
HANDLE t,t2,t3,t4;
int arg = 10;
if(!CreateTimerQueueTimer( &t, htimer,TimerRoutine, &arg , 10, 1,4))
{
SetDlgItemText(IDC_S,"not set");
}
else
{
SetDlgItemText(IDC_S,"set");
}
CreateTimerQueueTimer( &t2, htimer,TimerRoutine2, NULL, 100, 1, 2);
CreateTimerQueueTimer( &t3, htimer,TimerRoutine3,NULL , 1000, 1, 2);
}
VOID CALLBACK TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired)
{
one++;
char a[20];
itoa(one,a,10);
st1->SetWindowText(a);
}
VOID CALLBACK TimerRoutine2(PVOID lpParam, BOOLEAN TimerOrWaitFired)
{
two++;
char a[20];
itoa(two,a,10);
st2->SetWindowText(a);
}
VOID CALLBACK TimerRoutine3(PVOID lpParam, BOOLEAN TimerOrWaitFired)
{
three++;
char a[20];
itoa(three,a,10);
st3->SetWindowText(a);
}
|
|
|
|
|
shaina2231 wrote: i m creating 3 queutimers and after adding them in queue using 3 callbacks functions for each timer ,and calling one function after 10ms 2nd func after 100 ms,3rd func after 1sec
No you're not, you've set the parameters incorrectly. The 10, 100 and 1000 arguments are specified in the DueTime position. You've specified 1ms for the period. Also, the last parameter of CreateTimerQueueTimer is a flag argument. Looking at this page[^], the valid values for that parameter do not include 4...which is what you've used for one of the timers.
Your CreateTimerQueueTimer calls should look more like this:
CreateTimerQueueTimer( &t, htimer,TimerRoutine, &arg , 1000, 10, WT_EXECUTEINIOTHREAD);
CreateTimerQueueTimer( &t2, htimer,TimerRoutine2, NULL, 1000, 100, WT_EXECUTEINIOTHREAD);
CreateTimerQueueTimer( &t3, htimer,TimerRoutine3,NULL , 1000, 1000, WT_EXECUTEINIOTHREAD);
WT_EXECUTEINIOTHREAD is defined in winnt.h as 0x00000001 . If you're using VC6, do yourself a favour and install a modern Platform SDK. Then you won't need to do stuff like call LoadLibrary and GetProcAddress to get the CreateTimerQueue function's address - you can use the kernel32 import library - and you can use symbolic constants like WT_EXECUTEINIOTHREAD rather than numbers that you can get wrong (and you did get one wrong).
Also - the timer callbacks are likely to be called on different threads than the UI thread. That means that you possibly shouldn't be calling SetWindowText, as (I think) it sends a Windows message rather than posting it.
|
|
|
|
|
I have ported a old MFC appliction to VC8 and have everything but the context sensitive help working. What help system - HTML Help 1, MS Help 2, Windows Vista AP help, or ... is most appropriate to use in Visual Studio 2005?
Can you suggest any tutorials to lead me through the process also.
Thanks
Clayton
|
|
|
|
|
What systems are you hoping to deploy on? If it includes XP, then Vista Help isn't much good, I would have thought.
Also, MS Help 2 is primarily designed for Visual Studio[^], so isn't going to be that widely installed.
So - I'd go for CHMs myself.
|
|
|
|
|
Thanks, I was being overwhelmed by all the choices.
Clayton
|
|
|
|
|
I remember reading an article about how to correctly program for all font sizes and DPI's (eg. 96 and 120), but I can't find the article anywhere (it may not even be on CP).
Can anyone help me with a link to an article, or even book reference, about making your UI compatible for all font sizes and DPI's ?
|
|
|
|
|
|
Thanks David!
|
|
|
|
|
Hello
If any one has MFC Internals Ebook, by Scott wingo, I would request you to share the same with me.
Thanks in advance
Ritesh
Ritesh
|
|
|
|
|
Are you offering payment?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yes, I will pay you, if you can give me a softcopy of MFC internals.
|
|
|
|
|
Share your desktop, we'll share you.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Please share you money with us...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I need to let admin-user to change local area connection properties with in the program.
the program is written in mfc/c++.
currently i have an ugly piece of code that works only if i know the type of the card - as you can see in the OR statement. I found out that wireless cars always have "Wireless" in their name, however I couldn't find anything similar for LAN cards, any ideas?
Thanks!
Sky
CString LanIp,WLanIp;
CString Descr,ServiceName;
DWORD regEnumIndex = 0;
DWORD IPwasChanged = FALSE;
CString Value;
CRegistry Reg (HKEY_LOCAMACHINE);
CStringArray IpConfigPath;
CString IpAddress;
CString Key1("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\");
CString Key2("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\");
CEntity *Entity = m_pMgr->GetMyEntity();
if(Entity != NULL)
{
((CLanEntity *)Entity)->GetLanIP(LanIp);
((CLanEntity *)Entity)->GetWLanIP(WLanIp);
IPwasChanged = FALSE;
while(1)
{
if(Reg.EnumKey(Key1,regEnumIndex,Value) == FALSE)
break;
Reg.Get(Key1 + Value,"Description", Descr);
if(Descr.Find("Wireless") >= 0)
{
if(WLanIp == "0.0.0.0" || WLanIp == "")
continue;
Reg.Get(Key1 + Value,"ServiceName", ServiceName);
Reg.Get(Key2 + ServiceName,"IPAddress", IpAddress);
if(WLanIp == IpAddress)
continue;
Reg.Set(Key2 + ServiceName,"IPAddress", WLanIp);
Reg.Set(Key2 + ServiceName,"SubNetMask", _T("255.255.255.0"));
Reg.Set(Key2 + ServiceName,"IPAutoconfigurationEnabled", 0);
Reg.Set(Key2 + ServiceName,"EnableDHCP", 0);
IPwasChanged = TRUE;
}
if(Descr.Find("PRO/100") >= 0 || Descr.Find("Realtek") >= 0 || Descr.Find("Marvel") >= 0)
{
if(LanIp == "0.0.0.0" || LanIp == "")
continue;
Reg.Get(Key1 + Value,"ServiceName", ServiceName);
Reg.Get(Key2 + ServiceName,"IPAddress", IpAddress);
if(LanIp == IpAddress)
continue;
Reg.Set(Key2 + ServiceName,"IPAddress", LanIp);
Reg.Set(Key2 + ServiceName,"SubNetMask", _T("255.255.255.0"));
Reg.Set(Key2 + ServiceName,"IPAutoconfigurationEnabled", 0);
Reg.Set(Key2 + ServiceName,"EnableDHCP", 0);
IPwasChanged = TRUE;
}
}
}
|
|
|
|
|
skydiver135 wrote: I need to let admin-user to change local area connection properties with in the program.
Why can't they just use the Windows Admin Tools?
led mike
|
|
|
|
|
At my previous employer I was often working on network related code and was changing my IP address every 5 minutes for 8 hours. As you can imagine this grew tiring so I spent a weekend writing an application to change my network settings in a single mouse click to one of several options.
Here is a function I pulled from that application:
BOOL CNetworkToolBox::GetNetworkCardsFromIpHlpAPI(CStringArray *szCards)
{
BYTE *pBuf=NULL;
DWORD dwSize=0;
DWORD dwResult=0;
BOOL bConnected=FALSE;
PMIB_IFTABLE pMIBTable;
CString str;
GetIfTable(NULL,&dwSize,FALSE);
pBuf=new BYTE[dwSize];
pMIBTable=reinterpret_cast <PMIB_IFTABLE>(pBuf);
if(NO_ERROR == GetIfTable(pMIBTable,&dwSize,FALSE))
{
for(UINT i=0; i < pMIBTable->dwNumEntries; ++i)
{
if(MIB_IF_TYPE_LOOPBACK != pMIBTable->table[i].dwType)
{
if(MIB_IF_OPER_STATUS_CONNECTED == pMIBTable->table[i].dwOperStatus
|| MIB_IF_OPER_STATUS_OPERATIONAL == pMIBTable->table[i].dwOperStatus)
{
str.Format("%d@%s",pMIBTable->table[i].dwIndex,pMIBTable->table[i].bDescr);
szCards->Add(str);
}
}
}
}
delete []pBuf;
return bConnected;
}
You can check the dwType member of the MIB_IFROW Structure[^] and look for the value IF_TYPE_IEEE80211 which designates the interface as wireless. All other cards would be physical/virtual. I am using the IP Helper Library so you will need to include the following:
#include "Iphlpapi.h"
#pragma comment(lib, "iphlpapi.lib")
Btw, there are better ways to set the interface options than raw registry.
Best Wishes,
-David Delaune
|
|
|
|
|
It's possible that WMI[^] might be a better, more reliable approach.
This article[^] shows why WMI is better than searching through the registry for system information.
|
|
|
|
|
I have a question about CSocket and thread.
I have an application server C++/MFC (Visual Studio) that need to have 300 connection always open.
My server receive data from industrial machines and save data into a remote database.
On internet i have seen that many programmers use a thread for every connection that is open.
My application don't create directly a thread for every connection.
I only create a new CSocket object when i receieve a new connection request (i have a csocket that listen for this request).
So i have a list of 300 CSocket object.
I see that operating system / MFC library call OnReceive when machines send data to my server.
Inside the OnReceive() i write machine data in a dedicated file (there is a file for every industrial machine) .Another thread (this is the only working thread that i have created, reads sequentially all these files, do some computations and then sometimes write info into an SQL database.
So, my appliaction has a User Interface thread (created by the Visual studio framwork), a working thread that execute a loop to read all machine files to see if there is new data.
Then there are all these CSocket object that in an asyncronous way execute OnReceive to save data from machine into its file.
I am not sure that this is a good archietecture because with 300 connections my application has become slow.
May be that if i create a separate thread for every connection performance improves ?
When i create a csocket object indirectly i create a thread ?
Which is the difference ?
Thank you for your attention.
Emanuele.
|
|
|
|
|
|
My networking era ended without me actually trying out I/O completion ports.. That's there for years in my to-do list.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Once you get the hang of using them, they work extremely well.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you for your reply.
Emanuele.
|
|
|
|
|