|
what dos command you want to fire! actually all dos command has been encapsulated in win32 apis!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
hi all
this is the code to fetch data from mysql using vc++
but my problem is that data is not shown in info which i declare as cstring as
mysql return data in string
evrything is ok
but data is not shown in info variable please help me
GetDlgItemText(IDC_EDIT1,f);
info = select ID from login where name = \'" + f + "\'";
if ( ! mysql_query( myDB, info) )
{
res = mysql_store_result( myDB );
row = mysql_fetch_row( res );
}
thanks
hi
|
|
|
|
|
paras_s12 wrote: if ( ! mysql_query( myDB, info) )
Does info have the correct value prior to the call to mysql_query() ?
BTW, it's only been 92 minutes since you last asked this question. There's no need to post it again.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ask same you on mysql forum you will get faster reply!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I would like to be able to access the mainframe menu from a non-modal dialog box - in other words, if I press Alt+F, the main File menu should get activated... any idea how to achieve that?
Thanks in advance!
|
|
|
|
|
One way is to send key events to your main window from modeless dialog box. SendMessage() with WM_KEYDOWN and WM_KEYUP in proper sequence might solve your problem.
|
|
|
|
|
Thanks .. but that's a bit of a hack if you do not mind me saying so
I would not want to have to implement all the accelerators like this.
|
|
|
|
|
Try AfxGetMainWnd()->SetFocus() .
Or, send a user-defined message to the CMainFrm object that includes code to drop set focus to itself and then drop the menu. (this is the mehtod I would probably use)
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Do you mean I should call AfxGetMainWnd()->SetFocus() whenever the Alt key is pressed?
|
|
|
|
|
why not if that solves your problem.
Also, to my answer I can add - you don't need to implement all your accelerators but can simply do SendMessage on OnKeyDown with if Alt is down.
|
|
|
|
|
Noooo... I mean do it when you handle Alt-F in your dialog.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I can indeed trap this (WM_SYSKEYDOWN) but I would not want to have to change my code whenever the menu changes AND the shortcuts are not the same depending on the language - all of the sudden my code would depend on which resources were used.
|
|
|
|
|
You were indeed right about the AfxGetMainWnd()->SetFocus() !
Thanks for your help!
|
|
|
|
|
This is how I did it
BOOL CModelessDialog::PreTranslateMessage(MSG* pMsg)
{
switch ( pMsg->message )
{
case WM_SYSKEYDOWN:
if ( ( pMsg->wParam >= 'A') && ( pMsg->wParam <= 'Z'))
{
AfxGetMainWnd()->SetFocus();
return false;
}
break;
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
i am trying to give my XML parsing code UNICODE support. if UNICODE is not defined it works fine. but if i define it it gives some garbage values. (i am showing it in mag box) the problem is in the
dwFileRead = static_cast<dword>(fread(ptempXML, sizeof(TCHAR), dwFileSize, pfTempXMLBuf));
statement. what are the changes i have to make in the code. the file successfully comes in pfTempXMLBuf. but ptempXML shows garbage.
pfTempXMLBuf = _tfopen(tcsBufXMLFileName, _T("w+"));
m_pNode->Print(pfTempXMLBuf, 0);
fseek(pfTempXMLBuf,0, SEEK_SET);
dwFileSize = _filelength(fileno(pfTempXMLBuf ));
ptempXML = new TCHAR[dwFileSize + 1];
if(ptempXML)
{
memset(ptempXML, 0, dwFileSize); // Required otherwise ending char are junk.
fseek(pfTempXMLBuf,0, SEEK_SET);
dwFileRead = static_cast<dword>(fread(ptempXML, sizeof(TCHAR), dwFileSize, pfTempXMLBuf));
ptempXML[dwFileRead] = _T('\0'); // Required as the file size is most larger then the actual file contain read which appends junk at end.
rc = ptempXML;
delete []ptempXML;
}
|
|
|
|
|
|
sandeepkavade wrote: but if i define it it gives some garbage values.
How are you verifying this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I'm currently trying to get an n-ary tree implemented in C (I know, C++ would be so much better, but I'm stuck with it). Each node is a struct, which holds a pointer to a string, which is assigned whilst the node is being setup. Basically, I'm confused over the use of malloc and free; I don't think everything is being correctly freed at the moment.
Struct:
typedef struct node {
char *sData;
int iNumChildren;
struct node *nParent;
struct node *nChildren[MAX_NODES];
} treeNode;
addNode:
struct node* addNode(struct node *nParent, char *sData)
{
treeNode *temp;
int iNodeLevel;
if( nParent->iNumChildren < MAX_NODES )
{
temp = malloc( sizeof( treeNode ) );
temp->sData = sData;
...
return temp;
}
else
{
return NULL;
}
}
freeTree:
void freeTree()
{
int iRep;
int iFreed = 0;
char *sData;
treeNode *temp;
while( getNumChildren( root ) > 0 )
{
temp = root->nChildren[ root->iNumChildren - 1 ];
for( iRep = 0; iRep < iLongestPath; iRep++ )
{
if( getNumChildren( temp ) > 0 )
temp = temp->nChildren[ temp->iNumChildren - 1 ];
}
temp->nParent->iNumChildren--;
sData = temp->sData;
free( temp );
iFreed++;
printf( sData );
}
free(root);
iFreed++;
#ifdef _DEBUG
printf( "Freed %d nodes\n", iFreed );
#endif
}
As you can see, I've put in some code to check if the string was being freed, and it's not. However, I don't know how else this could be done; I'm not exactly a C guru.
Also, I did have a look around to see if there was anything similar, but all the code I found was in C++, which is no good for me. If anyone knows of something I could look at, I'd be supremely grateful.
Any ideas?
Sean.
|
|
|
|
|
The big question is how you call addNode and especially if sData has been allocated by alloc or do you call it like this addNode(pParent,"newNode")!
Because your freeNode frees the data, I think your addnode should allocate it as well... so I would rewrite it like this
in your addNode
temp->sData = sData;
temp->sData = malloc(strlen(sdata)+1);
strcpy(temp->sData,sdata);
Hoping this helps!
|
|
|
|
|
I did what you said, and it finally works! Not sure what I was doing wrong before, but thanks!
|
|
|
|
|
DarkWeaver5455 wrote: temp->sData = sData;
Has sData been malloc'd prior to calling addNode() ?
DarkWeaver5455 wrote: // This didn't work
Which means what exactly?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Whilst testing the functions, I was passing string literals in, which may be the problem.
Thinking about it now, because I technially didn't use malloc to allocate the memory for the strings (just passed in a lateral), I expect I can't use free to free the memory. Related to this, is the memory used by the string literals guaranteed to stay the same? And will it be freed when I close the app, or is there some way to free it whilst running?
|
|
|
|
|
DarkWeaver5455 wrote: Related to this, is the memory used by the string literals guaranteed to stay the same?
Yes.
DarkWeaver5455 wrote: And will it be freed when I close the app...
Yes.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for the speedy response, glad I have that sorted now!
|
|
|
|
|
how to add gif image to button
|
|
|
|