|
I can see the control at it's original position, but if I move it, it is not display anymore. In fact my special control is only able to draw himself in the first rectangle he received in the create function.
example:
MySpecialControl.Create(CRect(10,10,100,50),this,1);
this will work very well
I can see my control but when i try to move it that way:
MySpecialControl.OnNewSize(this,CRect(10,35,100,50));
OnNewSize is a member function that i have create
void CMySpecialControl::OnNewSize(CWnd *pParent,CRect MyRect)
{
//that way
MoveWindow(MyRect,TRUE);
//or that way (i have also try the two...)
SetWindowPos(pParent,
MyRect.top,
MyRect.bottom,
MyRect.Width(),
MyRect.Height(),
SWP_SHOWWINDOW)
}
Maybe there something I don't understand whit windows...
By the way I've try this
PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style |=WS_CLIPCHILDREN ;
return CView::PreCreateWindow(cs);
}
nothing...
do I have to call the OnSize(UINT nType, int cx, int cy) or something like that?
thank you
Remi Morin
Remi.Morin@Lyrtech.com
|
|
|
|
|
...now it work...
i don't know why...
and I don't know why it was'nt working...
Remi Morin
Remi.Morin@Lyrtech.com
|
|
|
|
|
I am using CInternetSession, CHttpConnection, and CHttpFile to get a file
from an HTTP server.
I am having a problem though determining if the initial connection succeeded
or not. If the server is 'off' then the code seems to execute despite my
'ifs' and produces an exception. If I put the statement throwing the
exception into a try-catch, it isn't caught, and crashes the program anyway.
CInternetSession net;
CHttpConnection* http = NULL;
CHttpFile* file = NULL;
http = net.GetHttpConnection("cabadam.homeip.net");
if (http == NULL)
{
status += "Failed to connect to server!\r\n";
dlg->edit_status.SetWindowText(status);
dlg->GetDlgItem(IDC_BUTTON_CONTINUE)->EnableWindow(1);
return 1;
}
file = http->OpenRequest(CHttpConnection::HTTP_VERB_GET,"version.txt");
try
{
file->SendRequest(); //THIS STATEMENT crashes the program even though it
is inside a try catch
}
catch (CInternetException pEx)
{
status += "Failed to connect to server!\r\n";
dlg->edit_status.SetWindowText(status);
dlg->GetDlgItem(IDC_BUTTON_CONTINUE)->EnableWindow(1);
return 1;
}
I have tried several different things, but I haven't been able to figure out
how to determine if it was unable to connect with the server.
Am I doing something wrong? Or is there an easier way to do this?
Thanks!
Adam
cabadam@houston.rr.com
|
|
|
|
|
try this:
try
{
http = net.GetHttpConnection("cabadam.homeip.net");
}
catch(CInternetException *ex)
{
...failed...
ex->Delete();
}
hope this helps
|
|
|
|
|
Oh duh!!
On the catch, I had the pEx as CInternetException, not CInternetException*
That did it...
thx
Adam
cabadam@houston.rr.com
|
|
|
|
|
When I fail to define a New Class correctly, how do I remove the New Clas from the project, si I can redifine it?
Richard
|
|
|
|
|
delete the files from the file view (highlight, press delete)
delete the actual files (from Explorer)
delete your .CLW file (from Explorer). this will be regenerated the next time you launch classwiz
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I'm done building my program, but I was just wondering what DLL to include with it. Some of my friend who doesn't own VC++ have trouble running it. Please help...
|
|
|
|
|
Use the Dependency Walker program that comes with MSVC++. It'll show you all the DLLs required to run your application; it's generally a good idea to package those into your installer, and have it install the DLLs if the ones present on the user's system are older.
You don't need to package them all, mind you -- you probably won't need to add Kernel32 into your installer, for example -- but MFC/OLE/COM DLLs should definitely be packaged.
|
|
|
|
|
just a tip: if its an MFC program goto Project>Options and on the combobox change "Debug" to "Release", then choose "Link MFC in static library" instead of "Link MFC dynamically" then click ok. goto Build(or run or comile whatever it says) and click "batch build" then select "Release" and click build. it will now build ur project in a folder called "Release" in ur main project folder, so in it you will find an executable which is linked statically and should contain everything you need.
Kuniva
Want, take, have.
(oh btw, best way of learning some language is by looking at examples, start large!) :p
|
|
|
|
|
Hello.
This portion of code works perfect in an aplication that conect to Access 2000 with a DSN ODBC.
CRecordset rs;
rs.Open(CRecordset::forwardOnly,"SELECT COUNT(*) FROM mytable",CRecordset::readOnly);
short nField=0;
CString str;
rs.GetFieldValue(nField,str);
long NumRecords = atol(LPCSTR(str));
Now I am porting the aplication to works with SQL Server 2000 and this portion of code give me the error: "State:S1002,Native ,Origin:[Microsoft][ODBC SQL Server Driver] Invalid column number".
In MSDN I have found "GetFieldValue calls the ODBC API function SQLGetData. If your driver outputs the value SQL_NO_TOTAL for the actual length of the field value, GetFieldValue throws an exception. For more information about SQLGetData, see the ODBC SDK Programmer's Reference"
I don't know if this is the problem. Anybody can tell me how can I solve this problem?.
Thanks in advance.
Tomás.
|
|
|
|
|
SQL automatically makes column 0 the bookmark column (which is useless unless you're using bookmarks). Start your column numbers at 1.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Thank you Bret.
This is not the solution.
I start with 1 and the error is "The index is not valid or the field name is incorrect".
I think the problem is another but I have no idea.
Tomás
|
|
|
|
|
Are you using a snapshot or dynaset recordset?
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I am using...
In the constructor:
m_nDefaultType = dynaset;
And to open:
rs.Open(CRecordset::forwardOnly,_T("SELECT COUNT(*) FROM mytable"),CRecordset::readOnly);
|
|
|
|
|
Actually, the anonymous guy is correct. You should use GetRecordCount(). And I believe the reason the other doesn't work is because I think the GetFieldValue gets a column value rather than a returned recordset value. So just do a plain open with a NULL query in order to get the whole recordset then do a GetRecordCount.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Seems like you just want the number of records in the database, so why don't you use the CRecordset::GetRecordCount() function.
|
|
|
|
|
Yes this is a solution, but too slowly because you need to check all the recordset to know the number of records.
MoveFirst();
DoWhile(IsBof()) {
MoveNext();
count++;
}
Is more eficient to do a SELECT COUNT(*) rather a DoWhile().
Tomás
|
|
|
|
|
No. You don't check it like this.
For example:
let's say you have a class CMyRecordset derived from CRecordset, and you use the default SQL, once you open the your RS class all you have to do is this..
CMyRecordset rs(db);
long lNumOfRecords;
rs.Open();
// if opens without any problem..
// this should give you the number of records you are looking for..
lNumOfRecords = rs.GetRecordCount();
|
|
|
|
|
Good day,
Does anyone know what exactly GetSuperWndProc() does? I keep getting this as an unresolved external in my embeddedVC program even though I never call it. If I override it it will compile fine but crashes on execution. I was wondering if anyone knows what its supposed to do so that I can implement it. Thanks.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Are you using any thirdparty libraries?
I don't think it a standard API function. I have never seen it before, and a search on all of MSDN don't get anything...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Sorry, my bad, its GetSuperWndProcAddr(). But no, I'm not using any third party libraries. In MSDN it says its obsolete and I don't need to override it but for some reason eVC keeps telling me its an unresolved external in all of my View classes and in my FrameWnd.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Hmmm, strange...
Anyway, you can read a lot about errors with GetSuperWndProcAddr here
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi there,
I am trying to create a SQL Server DSN using SQLConfigDataSource. Everything
seems ok, except for I can't figure out how to set the password part, to Windows Authentication as opposed to SQL Server Authentication. It appears that the latter one is the default and everytime I run my code it gets set to SQL Server Authentication.
thanks
|
|
|
|
|
add
\0TRUSTED_CONNECTION
to your
SQLConfigDataSource attributes
|
|
|
|