|
|
another way to get the file size (and it's portable too) is to use the ftell function:
FILE *f = fopen("foo.dat","rb");
long lFileSize = 0;
if (f != NULL)
{
fseek(f,0,SEEK_END);
lFileSize = ftell(f);
fclose(f);
}
|
|
|
|
|
I have setup two PCs for multilink connections using two modems each. One PC as dialer and another for receiving call. After the PCs got connected I used "RasEnumConnections" function to get the details of the connections. But I always get only one "RASCONN" structure. If only modem 1 is connected I get the value 1 for the subentry. If only modem 2 got connected I get the value 2 for the subentry. But if both modem got connected I only got 1 structure returned from "RasEnumConnections" and subentry=1. Why don't I get two RASCONN structure? How do I get all the RASCONN for all subentries ?
|
|
|
|
|
Hi !
My application is using an Access database through ODBC.
Now, if I want to make it run on a computer which doesn't have MS Office installed, it doesn't work because there is no ODBC Access driver.
Do you know if it is possible (and how) to install only an ODBC driver for Access and if this is freely installable ?
Thanks for your help !
Jerome
|
|
|
|
|
Hi also
You should install MDAC 2.7 and your problem is resolved. You can get it from MS for free. See ya Kurt
Fast Prototyping
|
|
|
|
|
Additional to what Kurt has said, you do not need to install MDAC on Windows XP or Windows 2003 as they come pre-installed with the OS.
IIRC Windows XP has at least 2.7 and Windows 2003 has at least 2.8
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I've being trying to get CString directly to float, but maybe I need to go through another class like 'const char *' first.
This is my problem code:
void CTest2Dlg::OnSelchangeList1()
{
int Stock; //Stock item quantity
int ListIndex; //Number of Items in list
int StrLen; //Length if string in list
double TAG; //Stock item cost inc. tax
float RRP; //Stock item rrp inc tax
float GP; //gross profit
CString WorkingStr; //complet list item string
CString TempStr; //extract of WorkingStr
CListBox * List1=(CListBox *)GetDlgItem(IDC_LIST1);
ListIndex = List1->GetCurSel(); //get selected item 0 based
List1->GetText(ListIndex,WorkingStr); //get WorkingStr from list
TempStr = WorkingStr.Mid(47,3); //Extract stock from WorkingStr
SetDlgItemText(IDC_STATIC4,TempStr); //Display stock on dialog
TempStr = WorkingStr.Mid(54,8); //Extract TAG Ex tax from WorkingStr
// problem code
sscanf(TempStr, "%f", TAG); //supposed to assign float TAG value of //CString TempStr. Not working
// end problem code
TAG = TAG * 1.1; //add 10% tax to TAG
TempStr.Format(_T("$%f"),TAG); //Assign TAG to CString
SetDlgItemText(IDC_STATIC5,TempStr);//Display TAG on Dialog
TempStr = WorkingStr.Mid(62,8); //Extract RRP ex tax from workingstr
SetDlgItemText(IDC_STATIC6,TempStr);//display RRP ex tax on dialog
//finish code when sscanf or other like function works
}
Thats the code. Can anyone show me how to get the value of TempStr into TAG? It shouldn't matter, but I'm using MS Embedded Visual C++ writing for Pocket PC
Thanks for any help you can give me!
Jochum Wittebrood
|
|
|
|
|
if you wonna convert from CString to float you can use following
CString sFloatString=_T("5.45");
TCHAR *tmpChar;
float fAValue = _tcstod( sFloatString.GetBuffer(0), &tmpChar );
That should pretty much do the trick
Greetz,
Davy
|
|
|
|
|
CString has an operator that returns a LPCTSTR so calling GetBuffer is not necessary.
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
how to create a lpr port in windows 2000 without user interface
ashees
|
|
|
|
|
Hello,
I am testing Rob Grove's SQLite wrapper called CppSQLite posted here at CodeProject, but I am running it in a Dialog based application. (CppSQLite is a great wrapper for SQLite, by the way).
I have some code that is adding lines to a ListBox instead of 'cout'ing it, but it is behaving strangely. At least I think it is! The following is a section of my code:
<snip>
try
{
int i, fld;
time_t tmStart, tmEnd;
CppSQLiteDB db;
SQLResultsStr.Format(_T("SQLite Version: %s"),db.SQLiteVersion());
m_List_Sqlite_Results.AddString(SQLResultsStr);
remove(gszFile);
db.open(gszFile);
SQLResultsStr = _T("Creating emp table...");
m_List_Sqlite_Results.AddString(SQLResultsStr);
db.execDML("create table emp(empno int, empname char(20));");
SQLResultsStr = _T("DML tests");
m_List_Sqlite_Results.AddString(SQLResultsStr);
<snip>
The problem is that no lines are added to the ListBox until the program completes execution. Then they all come flowing in at once!
The question is, why don't the m_List_Sqlite_Results.AddString(SQLResultsStr) statements add the string to the ListBox immediately after they are executed?
I hope this is clear!
Thanks,
Murrah Boswell
|
|
|
|
|
CListBox uses messages to add strings to the list. It may be that the paint messages are not being processed if your application is busy doing something like adding more entries within a tight loop.
You could force the update of the list control after each add with RedrawWindow() , that may have the desired effect.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hello,
Thanks for the reply!
The statements are all executed sequentially. I.e., no loops.
Could it be that I turned off precompiled headers for one of my modules that is pure C++ code? This is the module that has all the SQLite database manipulation functions. I could not get the module to compile with precompiled headers, so I turned it off.
The RedrawWindow() command did work, but it does seem like additional overhead.
Thanks,
Murrah Boswell
|
|
|
|
|
otrcomm wrote:
Could it be that I turned off precompiled headers
No, If you have sections of code that rarely change then it is advisable to turn on precompiled headers. Basically they speed up compilation as the compiler does not need to compile all code each time you compile. (You do need to compile it all at least once however!) It is not necessary to have precompiled headers turned on.
otrcomm wrote:
The RedrawWindow() command did work, but it does seem like additional overhead.
Basically what you are doing here is ensuring that the list is redrawn before the code continues to execute. If you do not do this then paint messages are normally processed when the code comes to a natural break.
You may also be able to ease the problem by running the SQL code in another thread (leaving the main thread to process the paint messages) the choice is yours.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hello,
Thanks again!
Since I am just testing the CppSQLite code too understand it better, I don't mind the overhead of the RedrawWindow() command now. However, under production code, I will take your advice and create a separate thread for the SQL code.
Another question. When you reply to my messages, I see parts of my message included. What setting at CodeProject do you have turned on to include the message you are replying too? I just get a blank textbox to reply in.
Thanks,
Murrah Boswell
|
|
|
|
|
otrcomm wrote:
When you reply to my messages
If you look at the text you are replying to, just underneath it is a button "Quote Selected Text". If you highlight the text and press the button it quotes it in the text of the reply.
In this case I highlighted "When you reply to my messages" and pressed the button.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hi all,
Does anybody know how image editors are made.I dont mean the image manipulation part ,but the canvas like thing we see in ms paint on which we draw ,erase .draw lines etc....I dont think it is a dilog.It would rather be a window , a paint window but how do we maintain it.say loading am image to a window is simple and i prefer the IPicture and IStream way of the win32 sdk.Once the image is loaded ,i even managed to draw on it ,like using moveto and line functions from the gdi.But the real trouble is how would i store the image temporarily.Say i have the image read from the file into the IStream and enclosed by IPicture .I render this from the IPicture to the window.Now i draw some lines over the image.Technically the dc is modified.Now how would i extract this modified dc into a buffer and latter on store it to a file.One suitable way is to Create a compatible dc and bitmap make a snapshot of this window,but it is not good,the image is not clear .How would i go around this situation.
Please help.
Vini
|
|
|
|
|
Hi,
How can I make a toolbar having buttons, which toggles their state from pressed to un pressed and vice versa like the toolbar of MS Paints?
|
|
|
|
|
Take a look at PressButton from CToolBarCtrl.
|
|
|
|
|
Hi,
I have a program which generates a 2D data and i want to plot it into a 3D surface Plot at the end of the execution of my program.
at present i am writing it into a text file and then i am importing it inot excel file to plot the 3D graph... i would like to have tht 3D graph to be viewed in my program itself....( my prorgam is a plain cpp file...and I am running it in VC++, i think i have to convert it into ActiveX file... but I am not familiar with it)
anyone plz help me on this....hhow to proceed
thanks in advance,
Suman
|
|
|
|
|
struct GroupConstant<br />
{<br />
CString** grpConst;<br />
};<br />
<br />
GroupConstant** m_pGrpConst;<br />
<br />
m_pGrpConst = new GroupConstant*[200];<br />
for(BYTE i=0 ; i<200 ; i++)<br />
m_pGrpConst[i] = new GroupConstant[50];<br />
<br />
CString** pstr = new CString*[4];<br />
for(BYTE i=0 ; i<4 ; i++)<br />
pstr[i] = new CString[2];<br />
<br />
<br />
GroupConstant** ppTemp = m_pGrpConst;<br />
GroupConstant* pTemp = (*m_pGrpConst);<br />
<br />
for(i=0 ; i<200 ; i++)<br />
{<br />
for(BYTE j=0 ; j<50 ; j++)<br />
{<br />
(*m_pGrpConst)->grpConst = pstr;<br />
(*m_pGrpConst)++;<br />
}<br />
(*m_pGrpConst) = pTemp;<br />
}<br />
m_pGrpConst = ppTemp;<br />
I have two double pointers. one is a content of the structure and other is pointer to the structure.
I initiate these double pointers as you see in the code. but now I have a problem with deleting these pointes.
how can I delete the double pointer included with structure and double pointer points to structur.
Thank you in advance.
|
|
|
|
|
hi all,
I have created MFC Program.But when I compilled it ,I got such a Error:-
"fatal error C1189: #error : include 'stdafx.h' before including this file for PCH"
Can anybody please tell me how to correct that Problem ??
Thanks in advance..
|
|
|
|
|
Put #include "stdafx.h" at the top of the .cpp file that causes the error.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
hi,
yes ..it is already in the top of the .Cpp file.But the Problem is appearing yet.
------This is the header file :------------------
// rtcsample.h : main header file for the RTCSAMPLE application
//
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
class CRtcsampleApp : public CWinApp
{
public:
CRtcsampleApp();
public:
virtual BOOL InitInstance();
};
This the .Cpp file-------------------------------------------
// rtcsample.cpp : Defines the entry point for the application.
include "stdafx.h"
// WinMain
//
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HRESULT hr;
UNREFERENCED_PAR
//extra code here
}
Can you tell me how to correct it?
OR
Is there a Problem in "stdafx.h" File?
|
|
|
|
|