|
I implemented this:
void CTimerDlg::RefreshTimer()
{
UpdateData(TRUE);
WINDOWPLACEMENT wp;
CTimerDlg::GetWindowPlacement(&wp);
if(&wp.flags == SW_HIDE)
{
}
else
{
OnBstop();
if (!::IsWindow(m_dRefreshDlg.GetSafeHwnd()))
m_dRefreshDlg.Create(IDD_REFRESH, this);
m_dRefreshDlg.ShowWindow(SW_SHOW);
OnBstart();
m_dRefreshDlg.ShowWindow(SW_HIDE);
}
}
When my timer reaches 1 hour I have it do the RefreshTimer() function.. I have a dialog pop-up unitl the OnBstop() and OnBstart functions complete.. I only want the dialog box to open if the program is not hidden.. this works fine but after this function runs.. it locks up the program.. any ideas
Rob
|
|
|
|
|
Hey Rob:
Sorry for the late reply. Hope the problem has already been fixed.
I tried to reproduce the problem on my end, but it seemed to work fine. If you still have the problem, can you please email me a test app? Just thought I might be missing something..
// Fazlul
fkabir@capitolsoft.com
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Thanks, every thing is working fine now.. I have a Multimedia Timer in my app, I have a event fire at a certian time and i dont want the event to be visible if the window is hidden.. I moved the function to the WM_TIMER instead of the Multimedia timer, everything seems to be working fine.. Thanks for the help.
Rob
|
|
|
|
|
There is also an IsIconic call which will tell you if its minimized I believe.
"I never met anyone I didn't like" Will Rogers.
|
|
|
|
|
Just thought I should add this...
As you said, ::IsIconic() will tell if the window is in minimized/iconic state, even though the window may still be in visible state (i.e. not hidden).
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
IsWindowVisible() to tell if a window is hidden.
IsZoomed() to tell if a window is maximized.
--Mike--
http://home.inreach.com/mdunn/
"Listen you footwarriors, can you hold down a bit with the firing? I've just got three impromptu weddings breaking out behind me!" -- Arthur Dent
your with and
|
|
|
|
|
I am using SetTopIndex() to make sure the last string insterted can be seen. However, it scrolls really slow. For example, if I try adding something to the list box every 1/4 second, it adds one that often until it has to scroll. Then it slows down, closer to 1 every second. It has the same affect as internet explorer when you try to use the mouse wheel and scroll really fast, the window does not scroll fast and ends up jumpy.
@ny !d3@s?
- John
|
|
|
|
|
I am trying to create an app in WTL that needs a tri-pane view. I create the splitters fine, but for some reason I can't get the splitter that is inside the splitter to layout properly. How would you call the update? The problem is that m_verSplit does not set the splitter over towards the middle. I have enclosed a sample of the code (removing things that don't necessarily pertain to the issue at hand). How does one address the top panes update function.
class CMainFrame : public CFrameWindowImpl<cmainframe>, public CUpdateUI<cmainframe>,
public CMessageFilter, public CIdleHandler
{
public:
DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)
CTestView m_view;
CTreeViewCtrl m_treeview;
CListBox m_listbox;
CHorSplitterWindow m_horSplit;
CSplitterWindow m_verSplit;
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
HWND hTemp;
RECT rect = { 0, 0, 1, 1 };
m_hWndClient = m_horSplit.Create(m_hWnd, rect, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0);
hTemp = m_verSplit.Create(m_hWndClient, rect, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0);
UpdateLayout(); // need this for SetSplitterPos
m_horSplit.SetSplitterPos(250, FALSE);
m_verSplit.SetSplitterPos(250, FALSE);
m_view.Create(m_hWndClient);
m_treeview.Create(hTemp, rcDefault, NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS, WS_EX_CLIENTEDGE);
m_listbox.Create(hTemp, rcDefault, NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LBS_NOINTEGRALHEIGHT, WS_EX_CLIENTEDGE);
m_horSplit.SetSplitterPanes(m_verSplit, m_view);
m_verSplit.SetSplitterPanes(m_listbox,m_treeview);
return 0;
}
};
Thanks,
Leo T. Smith
Senior Programmer/Analyst
Hartwick College
|
|
|
|
|
I am trying to do a project here at work where I need to communicate to our Cisco Routers/switches to retrieve MAC addresses of the systems that are connected to them. I have the MIB file but I don't know how to connect to the switches using this file.
I can manually communicate with the switches using a program call GetIf but I need to be able to query the switches automatically. I have been looking in the MSDN about the WinSNMP APIs.
Any help is much appreciated. Any books that talk about how to program SNMP with code samples would be great too.
Thank you.
Kelly Herald
Micronpc, LLC
|
|
|
|
|
Hello, the codegurus around the world.;)
Basically, you need any SNMP library to talk with SNMP Agnet (Router) on MIB files.
HP has its own SNMP library for Windows and Unix, and you download somewhere.
However, this SNMP library for Windows is only for Windows, so we can find
the other SNMP library without Windows DLL.
I guess that MIB files is included into the hardware of the routers,
so we can't use the enterprise OID in this MIB files at all.
Good Luck!
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hi,
I create a STRUCT. My STRUCT is composed only by BYTE datas.
I would like to know how can I do for use this STRUCT in a CByteArray or other.
For example : CByteArray.RemoveAll; CByteArray.Add; ...
If anyone can help me.
Best Regards
youssef
youssef
|
|
|
|
|
USe STL vector, or List if you want to use InsertAt and RemoveAt ( called different things in STL ) a lot.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
You may use the template version of CArray to hold your structure.
#include <afxtempl.h>
CArray<MyStruct, MyStruct&> myarray;
The second typename is used for passing arguments of your type to memeber functions (usually a reference to the main type).
See MSDN for more info.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
If I understand your question correctly, what I do is convert the struct into a class and have it inherit CObject as public. Once I do this, if I want the structure to be able to assign the values directly, I make all the values public. Then I make empty constuctor and destructor (unless you want to assign some default values). Then I will use CObArray. With this I can do everything I would do with CByteArray, but with typecasting:
CMyStruct *p = (CMyStruct *) m_array.GetAt(x);
If you wanted to do this cleaner (without the typecasting), you can create a new array class and have it do the typecasting for you, but I don't do this unless someone else will have to maintian the code.
class CMyStruct : public CObject
{
public:
int Val1;
int Val2;
CString Text1;
CMyStruct() {;}
~CMyStruct() {;}
};
I hope this helps.
Leo T. Smith
Senior Programmer/Analyst
Hartwick College
|
|
|
|
|
I would use MFC's CPtrArray to store ptrs to your structs.
Thus, if you have two objects of a struct called MyStruct, like this:
MyStruct struct1, struct2;
You can declare a CPtrArray object and then add them like:
CPtrArray m_Array;
m_Array.Add(&struct1);
m_Array.Add(&struct2);
You can get the structs back later like:
MyStruct* pStruct1 = (MyStruct*)m_Array.GetAt(0);
MyStruct* pStruct2 = (MyStruct*)m_Array.GetAt(1);
Hope this helps.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
CPtrArray takes void *, and you need to cast it yourself every time ? Oh.. the ugliness...
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Actually, you don't need to typecast when you call CPtrArray::Add() method. However, you're right, you need to do that when you get the struct back using GetAt() method.
If typecasting bothers you too much, you can instead use MFC's template class CTypedPtrArray (declared in afxtempl.h). In this case, you don't need to typecast while calling GetAt() method. Here is how this works:
CTypedPtrArray < CPtrArray, MyStruct* > m_Array;
m_Array.Add(&struct1);
m_Array.Add(&struct2);
MyStruct* pStruct1 = m_Array.GetAt(0);
MyStruct* pStruct2 = m_Array.GetAt(1);
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
It doesn't *worry* me, it's just plain ugly IMHO. But I'm an STL zealot, so I'm likely to take a dim view of MFC containers, I guess....
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Yes, it's kinda *religious* to talk about the relative advantages (or disadvantages) of using container classes supported by MFC and STL.
I guess, we all showed the original poster various ways of doing the same thing. It's up to him to decide which way to go.
Cheers.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
How can I use a Timer in a CListView?
(With the Timer I want to update the view)
|
|
|
|
|
This should be helpful:
CWnd::SetTimer
UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );
Return Value
The timer identifier of the new timer if the function is successful. An application passes this value to the KillTimer member function to kill the timer. Nonzero if successful; otherwise 0.
Parameters
nIDEvent
Specifies a nonzero timer identifier.
nElapse
Specifies the time-out value, in milliseconds.
lpfnTimer
Specifies the address of the application-supplied TimerProc callback function that processes the WM_TIMER messages. If this parameter is NULL, the WM_TIMER messages are placed in the application’s message queue and handled by the CWnd object.
Remarks
Installs a system timer. A time-out value is specified, and every time a time-out occurs, the system posts aWM_TIMER message to the installing application’s message queue or passes the message to an application-defined TimerProc callback function.
The lpfnTimer callback function need not be named TimerProc, but it must be defined as follows:
void CALLBACK EXPORT TimerProc(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent // timer identification
DWORD dwTime // system time
);
Timers are a limited global resource; therefore it is important that an application check the value returned by the SetTimer member function to verify that a timer is actually available.
Example
// This example shows how to use CWnd::SetTimer, CWnd::KillTimer, and how to handle WM_TIMER messages. A timer is set up to send a WM_TIMER message to the main frame window every 2 seconds in OnStartTimer(). OnStopTimer will stop the timer by calling CWnd::KillTimer. OnTimer was set up through class wizard to handle WM_TIMER messages for the main frame window. In this example the PC speaker will beep every 2 seconds.
void CMainFrame::OnStartTimer()
{
m_nTimer = SetTimer(1, 2000, 0);
}
void CMainFrame::OnStopTimer()
{
KillTimer(m_nTimer);
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
MessageBeep(0xFFFFFFFF); // Beep
// Call base class handler.
CMDIFrameWnd::OnTimer(nIDEvent);
}
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Hello,
I have the following code to make a push button check box, and it still draws the button as a check box.
// Create an check box push button.
m_blah4.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_CHECKBOX|BS_PUSHBUTTON, CRect(10,100,100,130), this, MY_BTN4);
Does anyone have any suggestions, as to what I am doing wrong?
Thanks in advance!!
|
|
|
|
|
|
Excellant that is what I needed!!!
Thanks for your help!!!
|
|
|
|
|
Hello all,
Here is my final solution to my original question:
// Create an auto check box.
m_blah4.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHLIKE|BS_AUTOCHECKBOX, CRect(10,100,100,130), this, MY_BTN4);
Now the button works like the push button check box in the resource.
Thanks to all of you who helped me!!
|
|
|
|
|