|
|
lauren wrote:
great minds nish great minds
Yeah I guess so
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Yep. Does the same thing and definitely much less typing and remembering of parameter values. Great catch!
By the way, check out what these macros expand to
Original C++ code
void SayHello2(PWSTR wstrName)
{
USES_CONVERSION;
AfxMessageBox(W2A(wstrName));
}
Expanded macros
void SayHello2(PWSTR wstrName)
{
int _convert = 0;
_convert;
UINT _acp = ATL::_AtlGetConversionACP() ;
_acp;
LPCWSTR _lpw = 0;
_lpw;
LPCSTR _lpa = 0;
_lpa;
AfxMessageBox((((_lpw = wstrName) == 0) ? 0
: (_convert = (lstrlenW(_lpw)+1)*2,
AtlW2AHelper((LPSTR) _alloca(_convert),
_lpw,
_convert,
_acp))));
}
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
|
Hi Tom
I am not at all experienced with ATL, but I was wondering why we cannot use W2A macro to achieve what the guy wanted to do!
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Like a lot of things in Windows development, there's more than one way to accomplish this task. I'm just more accustomed to using the Win32 functions. As I told Lauren, using the ATL macros is certainly a lot less typing and remembering of parameters and therefore, probably the better way to accomplish this conversion task.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
Tom Archer wrote:
Like a lot of things in Windows development, there's more than one way to accomplish this task. I'm just more accustomed to using the Win32 functions. As I told Lauren, using the ATL macros is certainly a lot less typing and remembering of parameters and therefore, probably the better way to accomplish this conversion task.
I think it's cool to know multiple ways to do something. It can be quite handy at times.
Nish
p.s. Got my mail? [with ppt]
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Especially something like this where the person may need to use the Win32 SDK.
Regarding the PPT. Yes, thank you. I replied to you.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
The most serious drawback of W2A, W2CA, xx2xx, is that for each invocation, new stack space is allocated. So, you can't really use them in a loop.
Other than that, I use them all the time.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
The most serious drawback of W2A, W2CA, xx2xx, is that for each invocation, new stack space is allocated. So, you can't really use them in a loop.
I think these issues have been partially improved in ATL 7.0
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Hello,
I have still problem for adding a column to DataGrid programicaly ...
Then i wanna join the Column to a Field from my DataSource, too ...
Please help me ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hello.
I have an idea for a program I would like to design and implement using C++. This program will produce a list of websites based on what the user wants to search. For example, let say the user enters "c++ programming." The program will log onto Google.com and conduct a search for "c++ programming." It will browse all responses pages and save all websites into a text file (one line per website URL). One done, the user will have a list of relevant websites.
From an implementation perspective, is the program above simple enough using C++ and Winsock? I should be able to setup a socket to connect to a search engine such as Google and/or Yahoo. That is about all I know right now. I do not know how to gather the information after I have connected to, say, a website. Please include a possible implementation using Winsock if you know of one.
Thanks,
Kuphryn
|
|
|
|
|
try ravi's webresourcegrabber class )on the front page of cp)
it looks like a good place to start
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
kuphryn wrote:
From an implementation perspective, is the program above simple enough using C++ and Winsock? I should be able to setup a socket to connect to a search engine such as Google and/or Yahoo. That is about all I know right now. I do not know how to gather the information after I have connected to, say, a website. Please include a possible implementation using Winsock if you know of one
I don't think winsock is a good idea for this. It is to low level, it'll force you to learn HTTP protocol (not to complicated, but still waste of time). I recommend WinInet, it's high level library which comes with IE and gives more comfortable access to HTTP.
As for information gathering, it is search engine dependent. Most use syntax like www.google.com/search?something or similar.
Felix.
|
|
|
|
|
Thanks.
I have never heard of WinInet. Is that part of MFC and IE? The authors of the network programming (Windows) I am reading have not mentioned WinInet.
Kuphryn
|
|
|
|
|
kuphryn wrote:
I have never heard of WinInet. Is that part of MFC and IE?
It comes with IE. It's a C based DLL. But there are plenty classes wrapping it. For more check http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/wininet/wininet.asp
Felix.
|
|
|
|
|
Thanks.
I will continue studying Winsock for now. I will look into WinInet after Winsock.
Kuphryn
|
|
|
|
|
hRsrc = FindResource(hInst, lpString, "AVI")
I'm confused about the third parameter. In the MSDN page for FindResource I see things like this for the 3rd param:
RT_ACCELERATOR Accelerator table
RT_ANICURSOR Animated cursor
RT_ANIICON Animated icon
RT_BITMAP Bitmap resource
... etc.
However, I can't find anything about using "AVI", "IMAGE", etc. for the third param.
The reason I ask is because I'm getting this error:
cannot convert parameter 3 from 'char [6]' to 'const unsigned short *'
When I use this statment:
HRSRC hRsrc = ::FindResource(hInst,
MAKEINTRESOURCE(nIDRes),
"IMAGE"); // type
Thanks!
|
|
|
|
|
are you compiling with
#define _UNICODE
?
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
No, I am not using #define _UNICODE. Should I be?
|
|
|
|
|
The error message says the compiler is expecting a unsigned short* , which indicates a Unicode string. If you don't know what Unicode is, you shouldn't be using it.
Now, the APIs that accept strings can be built for either ANSI or Unicode strings. To use the ANSI APIs, #define _MBCS either in your main header file before all #include statements, or (better) in your compiler options.
--Mike--
Buy me stuff! (Link fixed now)
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Hello,
I'm using MFC dialog based app. In it I have two dialog boxes Dialog1 and Dialog2. There is a Combo Box in Dialog2 that I want to populate with integer values obtained from Dialog1. The following explains what I want to do.
Dialog1.cpp
#include "Dialog2.h"
clear all contents from the Combo Box in Dialog2
while (number < 10)
{
...
if(some condition)
{
write whatever the 'number' value is to the
combo box in Dialog2
}
...
number++;
}
Does anyone know how I can do this or know of any document explaining this.
Thanks in advance,
Aoife
|
|
|
|
|
Use ResetContent() to clear the contents of a combobox. To add elements, use AddString() or InsertString() .
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello!
I am working on a custom control derived from CWnd, which I was hoping to put on CodeProject until I tried the control with the Create function (two step creation) in debug mode and it errored out. I then tried the control in Release mode and everything worked fine. Here is what my create function looks like:
//Function: Create
//Job: creates the NavBarCtrl
BOOL CNavBarCtrl::Create(const RECT& rect, CWnd* parent, UINT nID, DWORD dwStyle /* = WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VISIBLE*/)
{
//Make sure variables are valid:
ASSERT(parent && IsWindow(parent->GetSafeHwnd())); //parent must be a valid window
ASSERT(parent->GetDlgItem(nID) == NULL); //must be a unique dialog item
//Create the window:
if(!CWnd::Create(NAVBARCTRL_CLASSNAME, NULL, dwStyle, rect, parent, nID))
return false;
//Done:
return true;
}
The program crashes in debug mode sometime within the call to CWnd::Create. I have properly initialized the class name contained in NAVBARCTRL_CLASSNAME, since I used the same code Chris Maunder does in his grid control. Just a side note, I tried this code in debug mode first on a Windows XP machine, and was unable to get into the heart of the CWnd call to see what was wrong. Then I tried the code on a Windows 2000 machine and was able to debug enough to see that apparently the code was ASSERTing in the call to CWnd::Attach, on this line:
ASSERT(m_hWnd == NULL)
I examined the values for m_hWnd and found that, while it did not point to any place in memory (pointer had not been initialized), the value was not NULL. So I tried setting m_hWnd to NULL right before the call to CWnd::Create, but that didn't help. I am hoping someone can shed some light on this situation because it is really annoying to have to run all the programs that use this control in Release mode, and frankly, I hate miscellaneous errors. I would rather not send the code, but if it will help to solve this problem then I will do whatever.
Thanks in advance!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Alexander, how are you instantiating CNavBarCtrl? If m_hWnd is erroneous then it sounds like the instance of CNavBarCtrl might not be valid.
I don't understand why you couldn't step into the code CWnd::Create on XP.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|