|
I have written a custom control derived from CWnd. Basically I am not drawing the entire client rectangle. I do not want to obscure things behind the control. Now I have added the ability to click and drag a "thumb" piece on this control. Works great, except for the drawing.
What I am seeing is the control is not erasing the rectangle and I start getting "smearing"
Is there an easy way to grab an XOR map on this? I'm kinda new to MFC and am feeling my way through this.
Little help?
-JT
|
|
|
|
|
How can I send email from a program?
I would like to not have to go through an SMTP server.
On a related note, but off topic for this forum, I set up an SMTP server on my computer but when I tried to email my hotmail account through it, it said that it was 'unable to relay' for that email address. On the 'relay restrictions' page of the internet information services settings I have the 'Allow all computers which successfully authenticate to relay' check box checked.
Thank you for suggestions,
-Alex Griffing
|
|
|
|
|
See this:
http://www.codeproject.com/useritems/xymailclient.asp
I vote pro drink
|
|
|
|
|
Hey Alex,
Well, I suppose you have few choices.
MAPI
If you are willing to rely on the MAPI subsystem in Windows, you can certainly use MAPI to deliver the email. There can be issues with using MAPI from within NT Services (I guess we need to start calling these something else now with the advent of 2000 and XP), not sure if this is part of your objective. Depending on how and where your software will be distributed, it can also be problematic to ensure that your clients will configure MAPI properly. Mapi works well however, when everything is configured and running.
DUMB SMTP
There are lots of basic SMTP mail classes and code around, so if you don't need attachments, rich content, MIME etc., and you know you have access to a set up and working "smart" SMTP host, you could use something like this. Setup here too can be a little tricky. Your clients need to provide the name of the smart host, there really isn't any way to auto detect this.
SMART SMTP
** warning: I'm going to plug a product from my company
Depending on your needs, an option could be to use a comprehensive library like our Dundas TCP/IP toolkit. The toolkit includes all the SMTP and MIME stuff to handle attachments, rich content, etc., and it is also smart enough to be able to deliver the outgoing email directly to the recipients email server (no need for a relay host). The toolkit is 100% C++ and provided as source code, so it compiles right into your .exe w/o any external dependencies.
Check it out:
http://www.dundas.com/index.asp?products/tcpip/index.asp
HTH,
David
|
|
|
|
|
You've got 2 choices:
* MAPI (yuk)
* SMTP (easy)
I've done both -- and neither are great. SMTP has turned out to be easier, but you gotta learn the protocol. MAPI is a pain....
MAPI is a little more memory intensive, by making those memory calls, all of the MAPI suport gets loaded. SMTP only needs to load winsock...
As for your main problem -- it seems that you've not actually authenticated.
-p
|
|
|
|
|
The use of the const keyword is a point of problems between myself and others in my work group. I love to use it, but it is not used universally... (which is really annoying to me).
I really like the control that it places on the code. The fact that you can control which methods may be called on an object. A very effect way to denote which pointers are accessible to changeable objects and which should not.
But what I really want to know is this -- does it, in any way, affect the code generation, and the run of the program -- is there ANY sort of optimization that goes on here?
The thing I hear from people all the time is this -- "what's the point of doing that -- seems like a waste of time".
Should I just give up?
Regards,
-peter
|
|
|
|
|
The compiler can optimize because it knows the contents of the 'this' object won't change. For example take a mythical class method:
void A::SomeOtherMethod(int) const { ... }
void A::DoStuff(bool) const { ... }
void A::DoMoreStuff(int,bool) const { ... }
void A::Func() const
{
SomeOtherMethod ( m_nValue1 );
while ( ... )
{
DoStuff ( m_bFlag1 );
DoMoreStuff ( m_nValue1, m_bFlag1 );
}
} In this trivial example, the compiler knows m_nValue1 and m_bFlag1 will never change for the duration of Func(), nor will they be changed by SomeOtherMethod(), DoStuff(), or DoMoreStuff(), so it can keep m_nValue1 and m_bFlag1 in temp storage (like maybe a CPU register), instead of doing a 'this' pointer dereference every time those values are accessed.
"what's the point of doing that -- seems like a waste of time".
I could rant on here about people who think it's a hassle to take care with the code they write, but I won't because that's getting into religious debate territory.
--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
|
|
|
|
|
It's funny, I only recently have started to think more about 'const' and the fact that well written code will use it. Given that it never makes something work to declare it const, it's just something I knew about but didn't consider overmuch. I guess that's because I've taught myself to program, in the same way that the need to preserve namespaces rather than declare using on an entire namespcae is something I came to grips with by discussing it here.
I have nothing intelligent to add to what Michael has said ( no surprises there ), I just wanted to say as someone who constantly seeks to better himself and learn to do things *well*, and a veteran of many fights over STL before my workmates accepted it over MFC containers and ones they had written, all I can say is 'stick to your guns'. Get a copy of Stroustrup if you don't have one and quote it like the Bible. There is no way any remotely competent developer can argue with the guy who wrote the language without bringing some hefty evidence to the table.
Everyone at work uses STL now, to the point where I find it in the code instead of being called over to help impliment/optimise it. I'm sure you'll win your battle to, because you are right. Anyone who thinks it is a 'waste of time' to do things properly is a monkey.
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.
|
|
|
|
|
|
How can you tell if a window is SW_HIDE or SW_MINIMIZE.. I want to do a function, but if the window is hidden or minimized, I dont want the function to run.
Thanks,
Rob
|
|
|
|
|
Call ::GetWindowPlacement(..)
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
if(wp.flags == SW_SHOWMINIMIZED)
{
// window is minimized
}
Hope this helps.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
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
|
|
|
|
|