|
If you need solution of problem, use CDC* pDC = GetDC(); instead of CPaintDC dc(this);
|
|
|
|
|
I was reading about GDI and I believe that's the old way and I figured using CPaintDC was used for a reason. I'll check it out, thanks for the tip.
|
|
|
|
|
The problem is that the area in which you are drawing is not 'invalidated'. Breaking into the debugger has the side-effect of invalidating the entire window and that's why it works fine after that. Whenever you change the info, which by the way should be in your document instead of your view, you need to make the view invalidate the area that needs to be updated.
Take a look at this post[^] for more details on how to orchestrate the interaction between the document and its views.
Also, instead of this:
char * lpszText = new char[32];
sprintf (lpszText, "Files: %u", files->GetCount());
int nTextHeight = dc.DrawText(lpszText, [...] );
delete[] lpszText;
I suggest this:
CString sText;
sText.Format("Files: %u", files->GetCount());
int nTextHeight = dc.DrawText(sText, [...] );
It's cleaner, you don't need to worry about how much space to allocate, and you don't risk forgetting to free it.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I think I was doing the second way but I must have changed to C-Style strings for some reason, I don't know. I'm using CString's practically everywhere else. I'll take some time and read that link, thanks a lot.
edit: I just invalidated the view when the data is changed and it worked like a charm, many thanks. Practically that entire post was very informative, good call.
|
|
|
|
|
I would like to get handles to all icons in the system tray but have not been able to do this or find an answer in the MSDN.
Is it possible to get handles to all icons in the system tray and be able to remove them or modify them using the handle ?
Thankyou.
|
|
|
|
|
G Cross wrote:
I would like to get handles to all icons in the system tray but have not been able to do this or find an answer in the MSDN.
Here is answer to your query :-
http://www.codeproject.com/tools/ShellTrayInfo.asp[^]
"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
|
|
|
|
|
I've seen some articles with codes that has something to do with "Unicode".
How can I see the immediate effect of a program that's not "Unicode" compatible? because I'm still using char instead of TCHAR and i'm not using _T either but I haven't felt the effect of it yet.
|
|
|
|
|
Hi guys,
What database access technologies do you use for your applications at work? OCBC? DAO? ADO?
I am using VC6 to program my personal projects. At work, I am forced to use an inhouse database class, reason being it can be used in MFC and ATL projects. And also at work, we usually save data into our file format. So I have not really use any database technology.
I would like to use ADO for my personal projects. But it is very hard to find indepth information on how to use ADO in VC.
So what do you usually use?
Thank you in advance.
|
|
|
|
|
using ODBC is easy.
use CRecordset.
Iman Ghasrfakhri
|
|
|
|
|
I think it would not be user friendly to require my users to set the data source before they can use my application.
|
|
|
|
|
It is so easy to set data sourse in your program
CString str,DBName;;<br />
DBName = "Program path"+"\\DBname.mdb";<br />
str.Format("DSN=Chapar;DBQ=%s;READONLY=FALSE;EXCLUSIVE=FALSE;",DBName);<br />
SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)",str);
& to fined your program path use something like this:
GetModuleFileName(NULL,m_CurrentPath.GetBuffer(256),256);<br />
m_CurrentPath.ReleaseBuffer();<br />
m_CurrentPath.Delete(m_CurrentPath.ReverseFind('\\'),m_CurrentPath.GetLength()-m_CurrentPath.ReverseFind('\\'));
Iman Ghasrfakhri
|
|
|
|
|
Thanks Ghasrfakhri.
So I set it when my program is used for the first time?
|
|
|
|
|
CBasicNet wrote:
So I set it when my program is used for the first time?
Yes, or you can use a DSN-less connection.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
Thanks toxcct! I have seem that article before.
I would like to master ADO first before using a wrapper class which may hides some of the details from me.
|
|
|
|
|
i believe ADO have no class in the "constructor" classes...
that's why i fully use Mr Antolini's !
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Either ODBC or ADO. But I prefer ADO.
John
|
|
|
|
|
Can you give me some reasons for your preference?
|
|
|
|
|
CBasicNet wrote:
Can you give me some reasons for your preference?
I use ADO for everything.
Down Sides to ADO,
-I guess it can be a memory hog (I haven’t see this problem personally)
-Poorly documented, most of the documentation was written for VB, if you know that language than translating it shouldn’t be too difficult.
-ADO is COM based; in C++ working with COM can be a pain.
Positives
-Flexibility, ADO can connect to just about every data source you can think of. Excel, Access dbs, delimited files, SQL server, Oracle server, even LDAP (as memory serves)
-Changing data sources is easy enough just change the connection string.
-Dumping data from the data connection is extremely easy, ADO natively supports dumping data to an XML file, or you can execute a query that will dump data to a file. RE
objDB.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & _
"].[" & strWorksheet & "] FROM " & "[" & strTable & "]"
objDB.Close
-It supports calling stored procedures or strait queries.
-Changing the location of the where the data is; is a matter of changing the database connection.
That’s all I can think of for the time being. Before you start using someone else’s class I suggest hacking around with ADO. It’s very powerful but comes at a cost (steep learning curve).
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
I have very good experience with OLEDB templates and ATL.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Are you a glutton for punishment or OLEDB templates is different from the OLEDB I have heard of?
|
|
|
|
|
Are you using OLEDB through simple-to-use wrapper classes or you are using it 'raw'?
|
|
|
|
|
|
ODBC is more standarized and it would permit to change your database platform with only changing the connection string.
Marc Soleda.
|
|
|
|
|
hiho@ll
i need to convert a simple javascript i've found which generates a checksum to C
because i want to use it in a c prog
btw. i want to use this exact checksum code, so trieing another checksum algorithm isn't an option
here is only one line of code where i think the problem occures
i'll post the whole code as a reply so you can test it if you want
javascript:
<br />
c[r(i,3)]=(c[r(i,3)]-c[r(i+1,3)]-j)^(r(i,3)==1?j<<s[i]:j>>>s[i]);<br />
C:
<br />
c[r(i,3.0)]=(c[r(i,3.0)]-c[r(i+1,3.0)]-j)^(r(i,3.0)==1?j<<s[i]:j>>s[i]);<br />
r is defined as this:
<br />
#define r(x,y) (long long int)(floor(((x)/(y)-floor((x)/(y)))*(y)+0.1))<br />
and for testing you can use c as the following array:
<br />
long long int c[]={0x9E3779B9,0x9E3779B9,0xE6359A60};<br />
the problem is that i get wrong values within the C code
but the javascript code works
another problem was Visual Studio!!
i got complete different values for the whole code using visual studio
using the same code on Linux (i used cygwin) got me right values (for some part of the whole code)
don't know what the problem is/was but neither Visual Studio nor Linux got the one line described above work
i get wrong values
anybody knows the right conversion of the javascript code to C code?
thx@ll
|
|
|
|