|
If the validation fails, exit the OnOK and do NOT call the OnOK function in the Paerent class. There are better solutions for validation. Each time a field is updated, you should check wheter the information is valid. As long as not all information is valid, you can disable the OK button. Think of handlers like EN_CHANGE (EDIT field) or SELCHANGE (Listbox) etc. I normally add to each dialog a member function to do all validations. It is called each time the user changes anything.
|
|
|
|
|
What i am trying to do is make a console program that gets playlist info from winamp and stores 2 things, the track number and the corresponding track name and stores it into a vector that is a struct with and int and a char defined like this:
struct sIPlaylist
{
char *Name;
int Position;
};
vector <siplaylist> dPlaylist;
The problem that i am having is that after i do a loop and go through the entire playlist and store both values for each song when i try to recall it like this:
Console::WriteLine(dPlaylist.at(a).Name);
no matter what number i put at a the text is always the last song name in the playlist escentially all of the Name part of the vector are the same text. this is how the loop is defined:
void CWinamp::gEntirePlaylist()
{
sIPlaylist tmp; // i think this might be where my problem is but im reseting the values at the beginning of each loop
for(int i=0; i < wInfo.pTotal ; i++) // run the loop until the end of the playlist
{
tmp.Name="";
tmp.Position=i+1;
tmp.Name=gTrackName(i); // gTrackName returns a char * with the song name of playlist track number i
dPlaylist.push_back(tmp); // move the lastest info to the bottom of the vector
}
Console::WriteLine(dPlaylist.size());
Console::Write(dPlaylist.at(222).Position); // this works perfectly
Console::Write(". ");
Console::WriteLine(dPlaylist.at(222).Name);
}
This is the console output:
222. Benny Bennassi .... Whos your daddy
that song isnt actually number 222 but actually number 3111 which is the last song in the playlist.
Im not sure what im missing but i obviously have some part of my code wrong and i would really appreciate any help.
- Corntoe
-- modified at 4:53 Monday 3rd July, 2006
|
|
|
|
|
|
The problem is probably because you don't use the char* correctly. The problem is probably in the function gTrackName but it is difficult to see wihtout seing the code. You cannot simply copy a string into your char array just by using =.
It would be much more efficient if you use the string from the STL also:
struct sIPlaylist
{
std::string Name;
int Position;
};
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
I suppose "char * Name " field of all of your sIPlaylist objects keeps a pointer to a string which is build by gTrackName function. This string is overwritten by each execution of gTrackName function, that’s why you only see the last value.
A solution is to keep the name inside the sIPlaylist structure. You can first define it as
struct sIPlaylist
{
char Name[100];
int Position;
}; and then use string-copy function:
strcpy(tmp.Name, gTrackName(i));
In more elaborated program, you should use dynamic allocation, or better get the assistance of std::string class from STL. In MFC projects, you can use CString class.
I hope it helps.
|
|
|
|
|
Thank you thats what i was doing wrong! i can now call back all the information thank you!
|
|
|
|
|
i put the popup menu when we right click the listbox item.
by doing this follwing things.
1.i create a new class CMyList derived from CListBox
2. in that class i overwrite the COntext menu()
by following code
HMENU hmenu,hmenuPopup;
hmenu = LoadMenu(AfxGetApp()->m_hInstance,(LPCTSTR) IDR_MENU4);
hmenuPopup = GetSubMenu(hmenu, 0);
TrackPopupMenu(hmenuPopup, TPM_LEFTALIGN | TPM_LEFTBUTTON|TPM_RIGHTBUTTON,point.x,point.y, 0,m_hWnd, NULL);
.
now how can i handle this events.
|
|
|
|
|
if you write this code now what do you need i think you declare contextmenu
whitesky
|
|
|
|
|
|
I think you can add the TPM_RETURNCMD flag to the second parameter of TrackPopupMenu function. In this case the function will return the ID of the clicked menu item, or zero otherwise. Then do the action according to received ID.
|
|
|
|
|
hi,
I have one clarification, I just want to know how to call stored
procedures in CDaoDatabase.
After the submit button I need to call one stored procedure by name
STORE_PROCEDURE1 with input parameters as
name,no,mark1,mark2
By using ADO I think we can use like this below. I just want to know how
to use in DAO.
With AdoComm
.CommandText = "{call PROEX.KPP_LFE.PPP_INSTPP_EMBARQUE_AUX(?)}"
.CommandType = adCmdStoredProc
Set AdoParamRet = .CreateParameter("Retorno", adBSTR, adParamInputOutput,
, vfRsEmb)
Call .Parameters.Append(AdoParamRet)
.Properties("PLSQLRSet") = True
Set vfRsEmbRet = .Execute
i want to do the same thing in DAO using CDaoDatabse
Try again and again,
At last you will say
I don't know the meaning for impossible.,.
|
|
|
|
|
When you send a "New Message" we can see it and you don't need to send a new thread
whitesky
|
|
|
|
|
|
in Richedit i insert table than i need to set cursor position inside the table but i get it after table last row
chetan
|
|
|
|
|
how did you insert the table in the edit
ajeeshcv
|
|
|
|
|
in MFC control rich edit, i insert bitmap and table and save in file through streamout of msdn fun as .rtf file it save perfectly but when same file try to lode in richedit it load only table or text not bitmap , i use the class streamin for load in richedit of msdn
chetan Sheladiya
|
|
|
|
|
hi,
I have one clarification, I just want to know how to call stored
procedures in CDaoDatabase.
After the submit button I need to call one stored procedure by name STORE_PROCEDURE1 with input parameters as name,no,id,mark1,mark2
By using ADO, I think we can use like this below. I just want to know how to use in DAO.
With AdoComm
.CommandText = "{call PROEX.KPP_LFE.PPP_INSTPP_EMBARQUE_AUX(?)}"
.CommandType = adCmdStoredProc
Set AdoParamRet =.CreateParameter("Retorno", adBSTR, adParamInputOutput,
,vfRsEmb)
Call .Parameters.Append(AdoParamRet)
.Properties("PLSQLRSet") = True
Set vfRsEmbRet = .Execute
reply early
Try again and again,
At last you will say
I don't know the meaning for impossible.,.
|
|
|
|
|
hi plz tell me
in sdi application how we can go from one form to another form
as i dialog based we use domodal()
but we can use in sdi from one form to another
Ashish Dogra
MCA
Noida
|
|
|
|
|
Create your sdi application with a form view
|
|
|
|
|
yes sir i create it with form view but then i create a second form whose base class is CMDIChildWnd wher split window is created .
now i want to go from first forms menu to second form .
Ashish Dogra
MCA
Noida
|
|
|
|
|
Your second form should also be derived from CFormView. Use SetActiveView() of your mainframe window to switch between your forms.
|
|
|
|
|
Do you need to call one dialog
whitesky
|
|
|
|
|
sir i need to call a form
on which split window is shown
Ashish Dogra
MCA
Noida
|
|
|
|
|
Hope I understood your question
if you want to call dialog you can use from a variable from your dialog and use m_dialog.Create(ID_DIALOG) in your program and use m_dialog.Show(1);
whitesky
|
|
|
|
|
hi sir plz solve my problem
Ashish Dogra
MCA
Noida
|
|
|
|