|
try this:
CString text = "Jake#Caroline#Mark#Anthony#Sid#";
CString name;
int index=0;
while (AfxExtractSubString(name, text, index++, '#') {
if (name != "") {
// do something
}
}
|
|
|
|
|
One way to do is to copy the CString to a char buffer and strtok() your way through the buffer.
(Btw, if you're using the CP forums to get canned answers to your schoolwork, you're only hurting yourself.)
/ravi
"There is always one more bug..."
http://www.ravib.com
raviv@ravib.com
|
|
|
|
|
lolz dont worry, its not for school, i'm only 16 we dont get any computer studies in my school, lolz we dont even have computers at my school haha
Kuniva
|
|
|
|
|
Can you tell me how I copy a string to a char buffer? Sorry if this question is a bit stupid...
|
|
|
|
|
Stevieslu wrote:
Sorry if this question is a bit stupid...
The only stupid question is the one not asked! Here's how:
char szBuffer [LARGE_ENOUGH_TO_HOLD_STRING];
CString strMyString = "Whatever";
szBuffer [0] = '\0';
if (strMyString.GetLength() < LARGE_ENOUGH_TO_HOLD_STRING) {
strcpy (szBuffer, strMyString.GetBuffer (0));
strMyString.ReleaseBuffer();
} /ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
Hi All,
I was just wondering about something that has been bugging me ever since I saw something like this in Java. In practice, which type of statement would be more preferable if you were to call a class function inside the same class in C++?
class Object {
void func1() { this->func2() }
void func2() {}
};
or
class Object {
void func1() { func2() }
void func2() {}
};
Is there any performance differences between the two?
Also, I apologize if this code might look wrong. I just wanted a conceptual opinion.
Frank
|
|
|
|
|
No direrences....
Best Regards...
Carlos Antollini.
|
|
|
|
|
There's no performance difference. IMHO, you only need 'this->' when one of the method parameters has name colliding with name of another data member. In the example below, the parameter 'foo' hides the member 'foo', so you need to explicitly qualify it with 'this'. Of course, you can rename the SetFoo parameter 'foo' to 'theFoo', in such case there's no need for explicit 'this'.
class obj
{
public:
void SetFoo(int foo) { this->foo = foo; }
int GetFoo() const { return foo; }
private:
int foo;
};
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm new to c++ and wanted to implement a few api calls into a test project. Unfortunately, every call fails w/ the unresolved external symbol error. Why? I include windows.h and give the functions all required parameters. Here's a sample-->
#include <windows.h>
int main()
{
HWND hwnd=NULL;
ShellExecute(hwnd, "open","http:\\www.google.com",NULL,NULL,SW_SHOWDEFAULT);
return 0;
}
and i receive these errors-->
main.obj : error LNK2001: unresolved external symbol __imp__ShellExecuteA@24
Debug/load.exe : fatal error LNK1120: 1 unresolved externals
|
|
|
|
|
from MSDN:
Header: Declared in Shellapi.h.
Import Library: Shell32.lib.
You've obviously got the header, try adding shell32.lib to your libraries list in the options for your project.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
You need to link your application with Shell32.lib.
Michael
|
|
|
|
|
Hi all,
I want to know, What is Access 2000, DAO version ?
Because, in one of MSDN article about DAO:
[B]
"This article describes how to create an Access 2000 (Jet 4.0) database in Visual C++ 6.0."
and other part of that article:
"DAO 3.6 is installed with Office 2000."
Does Access 2000 install DAO 3.6 and DAO 4.0 ?
For using DAO 4.0 in my programs, i must write below source code ?
AfxGetModuleState()->m_dwVersion = 0x601;
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
The problem is that MFC supports only dao 3.0 but when you install Access you will have the 3.6 version of DAO.
Okey, when tou initialize the engine of dao with afxdaoinit mfc wil set access 3.0 but you can use dao 3.6 that you have in your machine because it was installed by access 2000, and for that you can use it you must set AfxGetModuleState()->m_dwVersion = 0x601...
That's it.
If you need a better explanation please looking for a issue of MSJ of year 2000.... (I think that in Febraury or march) where Paul Dilascia explain the problem....
best Regrards
Carlos Antollini.
|
|
|
|
|
Access2000 installs DAO 3.6 and Jet 4.0 - not the same thing. DAO is a set of COM objects that let you use the Jet db engine (which Access2000 is a front-end for).
DAO and Jet are related as ODBC ans SQL Server is - if that makes it any clearer
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Access2000 installs DAO 3.6 and Jet 4.0 - not the same thing. DAO is a set of COM objects that let you use the Jet db engine (which Access2000 is a front-end for).
DAO and Jet are related as ODBC and SQL Server is - if that makes it any clearer
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I wanted to get the text from an item in a listview control on my main dialog window but it gives me a debug assertion error:
CMyDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
CString Data = dlg.m_MyListcontrol.GetItemText(0,1);
}
Any ideas why??
The item in the list control exists, no doubt about that but is it maybe because the main window has already closed or something?
How do i do this?
Thanks
Kuniva
|
|
|
|
|
You are checking the value after the dialog has been destroyed hence all child controls are also destroyed. GetItemText does a SendMessage to the hWnd of the ListControl which no longer exists hence you get the assertion.
Save the value on the OnOK handler of the dialog to a CString member variable and then you'll be fine.
<br />
CMyDlg::OnOK()<br />
{<br />
m_strData = m_MyListControl.GetItemText(0,1);<br />
}<br />
<br />
<br />
CMyDlg dlg;<br />
m_pMainWnd = &dlg;<br />
int nResponse = dlg.DoModal();<br />
if (nResponse == IDOK)<br />
{<br />
CString Data = dlg.m_strData;<br />
}<br />
<br />
HTH
Jignesh
|
|
|
|
|
Good explanation.
Regards,
Alvaro
|
|
|
|
|
Oops, don't forget to call the CDialog::OnOK after you save the value - in my prev post.
|
|
|
|
|
Quick question,
I'm trying to use ON_EVENT and I can't seem to figure out what the dispid is.. I pulled the following from MSDN.. I cant make any sense of "dispid".. How can I figure out what value I need to enter for the dispid?
Thanks,
Rob Jones
ON_EVENT( theClass, id, dispid, pfnHandler, vtsParams )
Parameters
theClass
The class to which this event sink map belongs.
id
The control ID of the OLE control.
dispid
The dispatch ID of the event fired by the control.
pfnHandler
Pointer to a member function that handles the event. This function should have a BOOL return type, and parameter types that match the event's parameters (see vtsParams). The function should return TRUE to indicate the event was handled; otherwise FALSE.
vtsParams
A sequence of VTS_ constants that specifies the types of the parameters for the event. These are the same constants that are used in dispatch map entries such as DISP_FUNCTION.
Here is a sample of what I have.. How do I know what to put in for the dispid?
I used a "1" in this example and it works.. But if I add another control I can't seem to use the "1" again.
BEGIN_EVENTSINK_MAP(CSkinDemoDlg, CDialog)
ON_EVENT(CSkinDemoDlg, IDC_OK, 1 , OnClickOk, VTS_NONE)
ON_EVENT(CSkinDemoDlg, IDC_SKINSCROLLBAR1, 1 , OnChangeSkinscrollbar1, VTS_NONE)
END_EVENTSINK_MAP()
Rob
|
|
|
|
|
Hi,
I've tried to work with icon with .net, but I didn't manage to get the alpha information right. Thus I decided to look at the problem from straight c++ and gdi+.
I want to draw the icon e.g. from "a:\" into a bitmap. Doing so will ignore the alpha portion of the image.
Here's the painting code (it's a standard mfc app. Just add it into your view's OnDraw):
CPaintDC dc(this);
Graphics g(dc);
SHFILEINFO info;
DWORD_PTR hTcdf = SHGetFileInfo("a:\\",0,&info, sizeof(info), SHGFI_SYSICONINDEX | SHGFI_LARGEICON |SHGFI_ICON);
m_icon = info.hIcon;
Bitmap bit(50,50,PixelFormat32bppARGB);
PixelFormat pf=bit.GetPixelFormat();
assert(pf==PixelFormat32bppARGB);
Graphics g2(&bit);
HDC bdc=g2.GetHDC();
DrawIconEx(bdc,0,0,m_icon,0,0,0,NULL,DI_NORMAL);
g2.ReleaseHDC(bdc);
g.DrawImage(&bit,40,30);
DrawIconEx(dc,40,100,m_icon,0,0,0,NULL,DI_NORMAL);
The latter icon is drawn correctly the former not. Can somebody help?
Thanks,
Stefan
|
|
|
|
|
How do i get the text of an item in a listview control and possibly other subitems?
Kuniva
Want, take, have.
(oh btw, best way of learning some language is by looking at examples, start large!) :p
|
|
|
|
|
With CListCtrl::GetItemText
For example you have CString GetItemText(Item, subItem)
Best Regars....
Carlos Antollini.
|
|
|
|
|
I am looking for help on stuffing the keyboard. So like. No one here knows exact code to stuff like an "A" in the keyboard... Where are other good places to turn for help? I've been stuck on this for 3 days.
|
|
|
|
|
what do youn need?
Regards
Carlos Antollini.
|
|
|
|