|
gizmokaka wrote: I feel you disliked the question I asked, maybe because it's a newbe question
Not at all! We're all newbies at some point - I'm often a newbie!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
MICROSOFT MVP I some how doubt you are a newbe
|
|
|
|
|
I have lots of experience with C++, but there's so many different technologies
that most of the time I feel I know barely anything.
For example, I'd be a total newbie if I tried to build a website
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thanks for the encouragement.
have a great day.
|
|
|
|
|
Hi.
I'm reading C++ Primer Plus Fifth Edition by Stephen Prata. Chapter 7, page 326 : Ruler.cpp
example tries to explain how to write a interesting program. You see the code below and guess what? I see it too but it's just to complicated and the books explanation is not making that clearer. If i can't get it there is no point to continue to study c++. so i hope you can give me a hint
<b>CODE: </b>
#include <iostream>
using namespace std;
const int Len = 66;
const int Divs = 6;
void subdivide(char ar[], int low, int high, int level);
int main()
{
char ruler[Len];
int i;
for (i = 1; i < Len - 2; i++)
ruler[i] = ' ';
ruler[Len - 1] = '\0';
int max = Len - 2;
int min = 0;
ruler[min] = ruler[max] = '|';
std::cout << ruler << std::endl;
for (i = 1; i <= Divs; i++)
{
subdivide(ruler,min,max, i);
std::cout << ruler << std::endl;
for (int j = 1; j < Len - 2; j++)
ruler[j] = ' '; // reset to blank ruler
}
cin.get();
cin.get();
return 0;
}
void subdivide(char ar[], int low, int high, int level)
{
if (level == 0)
return;
int mid = (high + low) / 2;
ar[mid] = '|';
subdivide(ar, low, mid, level - 1);
subdivide(ar, mid, high, level - 1);
}
int life()
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
pourang wrote: so i hope you can give me a hint
Which statement is giving you trouble?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello everyone,
For entry point of a console application,
http://msdn2.microsoft.com/en-us/library/f9t8842e(VS.71).aspx
My understanding is it is important that the name of the function main exists, and it does not matter the prototype of main function, for example,
we can define main as int main () or int main (int argc, char** argv).
Is that understanding correct?
thanks in advance,
George
|
|
|
|
|
This[^] MSDN article defines the requirements for main() .
As a general rule, if you don't match the expected prototype, you can get linker errors.
Software Zen: delete this;
|
|
|
|
|
Thanks Gary,
Good reference. I want to confirm with you that,
int main( int argc[ , char *argv[ ] [, char *envp[ ] ] ] );
means three forms of main is legal?
int main( int argc);
int main( int argc, char *argv);
int main( int argc, char *arg[], char *envp[]);
regards,
George
|
|
|
|
|
When I am quickly throwing something together, I often use:
void main( void )
{
} It's not compliant, but not everything has to be.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks DavidCrow!
regards,
George
|
|
|
|
|
Hello,
I wanted to use SQLExec() but I did not get enough information about it.
Actually I wanted to store and use multiple SQL queries through CDatabase class .But I was unable to do it.
Is there any link available.
I did search through Google but finally I had to pose this question.
Sorry for te same.
Prithaa
|
|
|
|
|
Did you see Database section on the codeproject?
|
|
|
|
|
I agree with Hamid. This is probably more related to SQL than to the MFC classes you're using.
I would suggest asking on the SQL/ADO/ADO.NET board[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
Ok May be you are right but how can I ask this question to SQL board since I want to run SQL through VC++.
SQLExec() API seems right to execute multiple queries.
I wanted to know how should I use SQLExec() and how do I pass this handle (SQLHstmt StatementHandle) and what is the meaning of this SQL handle.
Where is the Database section of codeproject ?
Prithaa
|
|
|
|
|
prithaa wrote: I wanted to know how should I use SQLExec() and how do I pass this handle (SQLHstmt StatementHandle) and what is the meaning of this SQL handle.
I don't know what SQLExec() is, but I'm assuming you want to use ODBC
because you mentioned SQLHSTMT. If that's the case, you may want to study
this: Microsoft Open Database Connectivity (ODBC)[^]
The CDatabase and CRecordset MFC classes are wrappers for the ODBC APIs, handles,
etc. and are a bit easier to use than the straight APIs.
For the actual SQL queries, I still say your best bet is the SQL board.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
prithaa wrote: Actually I wanted to store and use multiple SQL queries through CDatabase class .But I was unable to do it.
Why not?
CDatabase db;
db.SQLExec("CREATE TABLE ...");
...
db.SQLExec("DROP TABLE ..."); Now if you actually wanted to have a result set sent back to you, you'd also need to use a CRecordset object.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi all,
I'am having a new tool bar with 5 buttons in my appication. Each button opens a form.
Now i should like to know how to automatically close the first form, when second form is opening ? like wise for all forms.
so at present time only one form should be visible.
can u please answer this question.
thanks
panthal
|
|
|
|
|
You can send WM_CLOSE to them,how did you make them?
|
|
|
|
|
thanks for your reply, i'll try this.
but How to send WM_CLOSE can u explain clearly please
R u asking about that tool bar buttons?
|
|
|
|
|
You must use of SendMessage.
|
|
|
|
|
There is more than a solution. I make it like this.
void CMainFrame::CloseMyFrame ()
{
CMDIChildWnd* pMDIActive = MDIGetActive();
CDocument* pDoc = pMDIActive->GetActiveDocument();
CMyView* pMyView;
POSITION pos = pDoc->GetFirstViewPosition();
while (pos)
{ pMyView = (CMyView*) pDoc->GetNextView(pos);
if (pMyView->IsKindOf(RUNTIME_CLASS(CMyView)))
{ CFrameWnd* pTempFrame = pMyView->GetParentFrame ();
pTempFrame->DestroyWindow ();
return;
}
}
return;
}
And, when I want to use it...
extern CFPSApp theApp;
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
pFrame->CloseMyFrame ();
I forgot...
I make it to close a specific Frame (that may be only ONCE at a time)
For other that I may be more times at once opened, I like follows
void CMainFrame::CloseMyFrame (CString szName)
if ((pMyView->IsKindOf(RUNTIME_CLASS(CMyOtherView))) && (pMyView->m_pParent->m_szName == szName))
This is because I use that views to modifify the parameters of an element. So I hold a pointer to the element that is being shown as a member variable in every window. So I get easy access to the data I have to show/modify and use it to differenciate between the 48 possible CFormViews that can be opened at once.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I'm making such a program.
The image has a rect bound to its edge, with control points.
Dragging the control points to rotate,enlarge(etc.) the image.
I'm using gdi+.
Any straight way?
Thanks.
-- modified at 1:04 Sunday 25th November, 2007
|
|
|
|
|
What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box.
SITUATION A
void CDlgControl::OnBUTTONCreateLadder() <br />
{ <br />
pLD = new CLadder; <br />
}<br />
void CDlgControl::OnBUTTONTestButton() <br />
{<br />
pLD->DestroyWindow();<br />
delete pLD;<br />
pLD = NULL;<br />
}
In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command in OnBUTTONTestButton(). Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command
7E41B517 call 7E4194A4
Debug assertion failure
File Winocc.cpp
When not using Debug, it simply fails on the same message
SITUATION B
The same exact code is used. However, prior to executing OnBUTTONTestButton(), I click the "X" box in the upper right corner of the CLadder window. Then I execute OnBUTTONTestButton(), and everything works just fine.
QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B?
Thanks
|
|
|
|
|
The "X" button issues a WM_SYSCOMMAND [^] notification to be sent to the window, with the wParam value set to SC_CLOSE . The default window handling closes the window.
With situation B, the window has already been destroyed by the time OnBUTTONTestButton is called, so a great deal of the normal window shutdown logic has already occurred. There's something wrong in the way you're handling the window destruction, or possibly in the CLadder destructor. Without seeing more of the CLadder code, it's difficult to say.
Software Zen: delete this;
|
|
|
|