|
In C it was legal to do the following(The C programming language by: Kernighan & Ritchie)
index(s, t)
char s[], t[];
{
return 0;
}
In C++ however this is NOT allowed!
I'm thinking this is what would flag this error.
Perhaps you have something like
void MyFunc();
{
}
or maybe you've missed the open close brackets around the funtion
void MyFunc; //It looks to me more like a variable then a function so the compiler would also get confused.
Just some suggestions.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Graphics graphics(dc.m_hDC);
Rect rect(20, 20, 100, 50);
Rect closingRect;
GetClientRect(closingrect); <- problem here
GraphicsPath path;
path.AddRectangle(rect);
// a region based on the path.
Region region(&path);
//clipping region
graphics.SetClip(& region);
//colour it just to see it
Pen pen(Color(255, 255, 0, 0));
graphics.DrawPath(&pen, &path);
Image image(L".\\banner.gif");
graphics.DrawImage(&image, 50, 50);
How do I figure out the size of the client rect? Using GetClientRect(closingrect) produces this error:
cannot convert parameter 1 from 'class Gdiplus::Rect *' to 'struct tagRECT *'
How to get the ClientRect using GDI+?
|
|
|
|
|
RECT midrect;
GetClientRect(&midrect); <- no problem here anymore
Rect closingRect(midrect.left, midrect.top, midrect.right - midrect.left, midrect.botton - midrect.top)
There might be minor spelling-errors because I'm just writing the code in IE...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Thank you Anders!!
I didn't understand struct RECT and Rect; know I can see the light. I'v notice things are a bit different between GDI and GDI+.
Anders Molin wrote:
Money talks, but all mine ever says is "Goodbye!"
I tell that to my wife; she still don't get it. LOL
|
|
|
|
|
I have a dialog app that runs for a while and gathers some information.
It then writes that information to three different text files in a tab delimited format.
I have an access database containing 3 tables (corresponding to the three text files). I also have a macro in the database that erases existing contents of the 3 tables, and then reloads the updated information from the text files.
Right now, I have to manually open up the access database and run the macro.
I am looking for a way to do it from within the program and save the trouble of having to open up the database myself.
1) Is it possible to get rid of the text files and macro and perform the actual erasing and importing of data from within my app? I'm not sure where to start on this one.
2) If that would turn out to be difficult, would it be possible to simply tell the database to run the macro?
If someone could give me some tips and point me in the right direction, I'd appreciate it..
Thanks for your help!
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
Of,course you can read data from file and put it in database,use CFile or CStudioFile to
read from files,then with ADO functions put it in database.
For the second way you mentioned I know SQLServer do it but I don't know about Access?
You can check this link about the second way:
http://lnrpc2.irb.hr/ebooks/0672313502/ch06/ch06.htm#SQLStoredProcedures
Mazy
You can find a solution (even a foolish one) for all problems (even big ones)
|
|
|
|
|
I have some local variables declared inside while loop
but the compiler does not recognize them when i try to use them outside of this loop?
can anyone tell mo how to solve this problem?
here is the code if you want to look at it!
case 'B':
{
count = 0;
while((c = cin.get()) != ' ')
{
inputLine[count] = c;
count++;
}
inputLine[count] = '\0'; //input line is storing the SS# here
count = 0;
//Here starts my binary search again
int low =0, mid, high=14;
while (low <= high)
{
mid = (low + high)/2;
// here i create a temporary investor to hold data of Buyer
Investor* tempIT = (*tempInvestors).getInvestor(mid);
int tempAccount = (*tempIT).getAccountBalance(); //AccountBalance Of Buyer
if (strcmp((*tempIT).getSocialSecurity(),inputLine ) < 0)
low = mid + 1;
else if (strcmp((*tempIT).getSocialSecurity(),inputLine ) > 0)
high= mid - 1;
else
mid = mid;
}
while((c = cin.get()) != ' ')
{
inputLine[count] = c;
count++;
}
inputLine[count] = '\0';
count = 0;
char tempTicker[30];
strcpy(tempTicker,inputLine); // now tempTicker stores thtickerSymbol
// Here i'm performing another binary search to look for the
// specific stock that has that same stockTicker
int lo =0, mi, hi=14;
while (lo <= hi)
{
mi = (lo + hi)/2;
Stock* tempST = (*tempStocks).getStock(mi);
int tempStockPrice = (*tempST).getCurStockPrice(); // storing the stockprice in tempStockPrice
if (strcmp((*tempST).getStockTicker(),inputLine ) < 0)
lo = mi + 1;
else if (strcmp((*tempST).getStockTicker(),inputLine ) > 0)
hi = mi - 1;
else
mi = mi;
}
while((c = cin.get()) != ' ')
{
inputLine[count] = c;
count++;
}
inputLine[count] = '\0';
count = 0;
int tempNumShares = atoi (inputLine); //tempInt is storing number of shares now.
if ( tempAccount >= (tempStockPrice * tempNumShares))
}break;
--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
C:\My Documents\DataStru\main.cpp(295) : error C2065: 'tempAccount' : undeclared identifier
C:\My Documents\DataStru\main.cpp(295) : error C2065: 'tempStockPrice' : undeclared identifier
C:\My Documents\DataStru\main.cpp(297) : error C2143: syntax error : missing ';' before '}'
Error executing cl.exe.
main.obj - 3 error(s), 0 warning(s)
|
|
|
|
|
I have some local variables declared inside while loop
but the compiler does not recognize them when i try to use them outside of this loop?
You're pointing to the solution yourself: declare those variables outside the loop.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
In the old days, compilers used to let you declare variables inside loops and still use them outside. However, it was decided to be bad practice, so modern compilers won't let you do it. Declare them outside of the loops beforehand if you wish for them to remain valid.
Simon
C++: Only friends can see your private parts.
Sonork ID 100.10024
|
|
|
|
|
make sure you are running win200, NT4.0 or winXP before downloading the sdk.
I am running 98se and spent a few days downloading it over 56k to find it wont install.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
Hi
I've always used the #ifndef guard to prevent multiple inclusion of a header file. I'm now considering to switch to #pragma once instead, much cleaner. But how widespread is this kind of compiler directives? Can I compile my code on most unix compilers if I use #pragma once?
|
|
|
|
|
Seems like #pragma once is recongnized by different compilers, some of them for the UNIX environment, but IMHO resorting to it is a bad idea, because it is not standard, and the #ifndef guard does the job in a very reasonable and widely known fashion.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
#pragma commands are by definition compiler-specific. If some *nix compilers support it too, great, but the world of *nix compiling is pretty hairy due to all the variants of OSes and compilers. Stick to the #ifndef method which is guaranteed to work everywhere.
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I have 2 questions the first is there a simple way to change the font size of a particlar control (eg. listbox).
The second is that I have a simple function (attached) which just reads a file and places it's textual contents into the clipboard. When I paste the info in notepad it is one continuous line with the crlf characters a little boxes though if i paste into other things (like in visual studio) it is fine. Is there some way I can preserve the carriage return/line feeds in the clipboard so that pasting into notepad and anything else will have the proper contents of the file?
EmptyClipboard();
GlobalBuff = GlobalAlloc(GMEM_MOVEABLE,size+1);
buffer = (char*)GlobalLock(GlobalBuff);
while(!feof(file)) {
fread(readbuffer,1,255,file);
if(ferror(file)) {
MessageBox(NULL,strerror(errno),"Error",MB_ICONERROR);
exit(1);
}
strcat(buffer,readbuffer);
memset(readbuffer,0,strlen(readbuffer));
}
GlobalUnlock(GlobalBuff);
if(SetClipboardData(CF_TEXT,GlobalBuff) == NULL)
return FALSE;
CloseClipboard();
If posting of this code is not appropriate please let me know and forgive my insolence.
Any help or suggestions are greatly appricated.
Thanks,
Sean Cody
|
|
|
|
|
As for the first question, use SetFont . Read Mike Dunn's C++ FAQ for common mistakes prople make when using this method.
With regard to your second problem, I guess what's happening is that notepad requires lines to be separated by CR-LF pairs ("\r\n" in C++ code) and you are feeding it with LF separated text. Try opening your file in binary mode ("b" flag in fopen ), that should fix the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I should have specified I am only using C and the bare Win32 API (no MFC) so that method will not work for me.
Though the fopen suggestion worked great. Thanks!
Sean Cody
|
|
|
|
|
I should have specified I am only using C and the bare Win32 API (no MFC) so that method will not work for me.
There are direct equivalents in Win32: message WM_SETFONT , Win32 function CreateFont ... so you should have no problems translating the solution to raw C/Win32.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'll look into that.
Thanks again.
Sean Cody
|
|
|
|
|
Hi
I have a very little problem, but still it is a problem so please if you know any solution write me back.
How do you write this 2^4 in C++? When I write it in the program the compiler, compiles it as 2+4=6 when it should be 2*2*2*2.
thanks!
|
|
|
|
|
2^4 = 0010 ^ 0100 = 0110 = 6 which would explain why you are getting 6 as a result.
I would suggest using the following function located in math.h
double pow( double x, double y );
Sean Cody
|
|
|
|
|
There isn't an exponential operator in C. However, you do have the pow function.
Sort of sucks...
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
^ is the XOR operator in C. As others have said there is no raise-to-power operator.
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I am drawing something on the OnPaint or OnDraw Method which some times go beyound the Client Area so Scroll Bar activated. After that user can do any thing.
Through any event I want to convert whole client screen in to BMP. Problem is that when I took the Client Window Handle it is not giving the Data which is beyond theClient Screen (i.e., currently not visible but visible through scrolling).
What I do to grab whole thing which I draw on the Client View.
I am looking for any Code . . . any idea . . . any . . .
Thanks in adnavce.
|
|
|
|
|
I would create a memory bitmap the required size, select it into a memory DC, and call OnDraw(&memory_DC). The memory bitmap will now contain the entire view, independant of the window size.
---
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
The ATL declarations in stdafx.h:
// the following lines are required for ATL support
#include "atlbase.h"
extern CComModule _Module;
//#include "atlcom.h"
#include "atlapp.h"
#include "atlwin.h"
#include "atlctrls.h"
#include "shellapi.h"
#include "atlctrlx.h"
The usage of CHyperLink:
CHyperLink MyLink;
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
MyLink.SubclassWindow(GetDlgItem(hDlg,IDC_MYEMAIL));
return TRUE;
The errors:
C:\WINDOWS\Desktop\WP\WulframPoller.cpp(1173) : warning C4003: not enough actual parameters for macro 'SubclassWindow'
C:\WINDOWS\Desktop\WP\WulframPoller.cpp(1173) : error C2059: syntax error : '('
Any idea what I'm doing wrong?
|
|
|
|