|
Thanks for your both of your posts - excellent information. I figured it out and it's working as intended with your changes.
|
|
|
|
|
You should be probably be using CComVariant s instead of raw VARIANT s; both for consistency and to minimise the risk of leaks.
Steve
|
|
|
|
|
Thanks for that. I'm converting an existing project from PC to PocketPC. They recently also converted from using a DLL to an ActiveX control which, of course, all the underlying interfaces must be changed to encompass that, too. Of course, the interface to the OCX uses all VARIANTs.
I'm definitely going to look into using CComVARIANT vs rax VARIANTs. I'm quickly determining that converting their code from chars, int, UINT, etc, is becoming extremely tedious to say the least.
|
|
|
|
|
CODE SNIPNET
m_nFormat= DT_NOPREFIX | DT_LEFT | DT_WORDBREAK | DT_EXPANDTABS | DT_EDITCONTROL;
CClientDC dc(pWnd);
UINT nFormat = m_nFormat | DT_CALCRECT;
dc.DrawText(strText, cellRect, nFormat);
int nTotalPadding = (2 * m_nTextPadding);
lpItemStruct->itemWidth = cellRect.Width() + nTotalPadding;
lpItemStruct->itemHeight = cellRect.Height() + nTotalPadding;
The height returned by the CDC::DrawText is not consitent, it behaves different for string of same length example..
1) String full capital letters of length say 160 it returns ==> 81
2) String full capital letters of length say 160 it returns ==> 81
3) String full small letters of length say 160 it returns ==> 100
Please help on this
for thendral
|
|
|
|
|
I'm trying to make a program to open a file named stats.dat and input name, batting average, and home run amount. So far I have:
#include "stdafx.h"<br />
#include "statistics.h" <br />
<br />
#include <fstream><br />
#include <iostream><br />
#include <string><br />
<br />
using namespace std;<br />
CWinApp TheApp;<br />
<br />
<br />
<br />
int main()<br />
{<br />
char end, lc;
int hr_num;
float bat_avg;
string name;
ofstream outfile;
<br />
outfile.open("FLOATS.DAT",ios::app);
<br />
lc = 'y';<br />
<br />
if(outfile)
{ <br />
while (lc = 'y')
{<br />
cout << "Enter the name of the player: ";<br />
getline(cin, name);<br />
outfile << name<<endl;<br />
cout << "Enter the batting average of the player: ";<br />
cin >> bat_avg;<br />
outfile << bat_avg<<endl;<br />
cout << "Enter the player's home runs: ";<br />
cin >> hr_num;<br />
outfile << hr_num<<endl;<br />
cin.ignore(80, '\n');<br />
cout << "Would you like to enter information for another player? Enter 'y' or 'n': ";<br />
cin >> lc;<br />
}
}<br />
else
{<br />
cout << "Error opening file.\n";
}<br />
outfile.close();
<br />
return 0;
}<br />
<br />
My problem is that after the .exe runs through once and will skip lines the second time through. All help is appreciated
|
|
|
|
|
klutez123 wrote: while (lc = 'y') //
If you'll put constants on the left side of the operator, you won't have such problems. Having while ('y' = lc) , the compiler would have immediately told you the problem.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
klutez123 wrote: while (lc = 'y')
my answer is certainly not related to your question, but are you sure you didn't want to write this instead ?
while (lc <code>==</code> 'y')
|
|
|
|
|
Totally unrealated to your question, but this
char end, lc;
is an example for a very bad comment.
Everyone who knows a little C++ knows the he read a char variable declaration before he even comes to reading the comment.
Write what the role of the variables will be, comment why , not what .
Failure is not an option - it's built right in.
|
|
|
|
|
I would even go as far as saying that the comment is plain wrong. He is not declaring char, he is declaring the variables end and lc.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
I'd like to draw pixels in a game, which isn't programmed by me(e.g. Warcraft 3, Halo, etc.(DirectX games)) (like XFire).
The pixels should be on top of the game (after the game has rendered, my pixels should be drawn).
I thought about something like a Hook for drawing (when the game is refreshing screen,
the Hook of my application is bing activated and I can draw my pixels).
Best would be a non-MFC Code (I usualy use normal Win32).
|
|
|
|
|
You can draw pixels on the whole area of your screen, by locking on the display context device
//this example draws sloping straight line
case WM_PAINT:<br />
hdc=CreateDC("DISPLAY",NULL,NULL,NULL); <br />
MoveToEx(hdc,15,15,NULL);<br />
LineTo(hdc,150,150);<br />
DeleteDC(hdc);<br />
break;
You can draw on the window you choose with it's process PID using these functions:
long lp=0;<br />
EnumWindows((WNDENUMPROC)EnumProc,lp);
bool __stdcall EnumProc(HWND hWnd,long)<br />
{<br />
unsigned long* pPid;
unsigned long result;
void *hg;
unsigned long id;<br />
<br />
if(hWnd==NULL)<br />
return false;<br />
<br />
hg = GlobalAlloc(GMEM_SHARE,sizeof(unsigned long));<br />
pPid = (unsigned long *)GlobalLock(hg);<br />
<br />
result = GetWindowThreadProcessId(hWnd,pPid);<br />
<br />
if(result){<br />
if(*pPid==MyPID)
{<br />
WindowYouWantToDrawOn=hWnd;<br />
return false;<br />
}<br />
}<br />
else{<br />
GlobalUnlock(hg);<br />
GlobalFree(hg);<br />
return false;<br />
}<br />
GlobalUnlock(hg);<br />
GlobalFree(hg);<br />
return true;<br />
}<br />
hdc=GetWindowDC(WindowYouWantToDrawOn);
And now you can use your new hdc to draw pixels on the concrete window but I don't know how to synchronize your drawing program with some other program's window and it's refresh method.
-- modified at 5:56 Tuesday 20th February, 2007
|
|
|
|
|
|
hmm, it would work by using a thread, but not realy good.
The line is sometimes disappearing when I'm ingame.
Does somepne have a better idea?
|
|
|
|
|
It's no problem drawing anywhere on the screen but how are you going to time redraws properly
as the game refreshes it's screen?
Great job, team. Head back to base for debriefing and cocktails.
|
|
|
|
|
Does no one have a better idea?
the idea by drawing with GDI isn't working really good!
|
|
|
|
|
How can i change the minimize and maximize boxes icons in window?
|
|
|
|
|
urid wrote: How can i change the minimize and maximize boxes icons in window?
To what?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Owner draw and overwrite CWnd::OnNcPaint .
But I have no practical experiences with that.
Failure is not an option - it's built right in.
|
|
|
|
|
And also on the codeproject is articles about insert buttons to system menu and change color did you search codeproject
|
|
|
|
|
Sorry I confused some where. so let me post this massage again. Any body kwown please show me how to use List Controlfor in my case that is explained as following:
In my dialog, I created two ListBox1 and ListBox2 with multiline and 1 button Send. So when I push button send the String ar row 1 form ListBox1 will be send to ListBox2, that means the string in row 1 of List control 1 will be disappeared and insert to row 1 of ListBox2, the sequence is run step by step up to there is no string in ListBox1
Thank very much.
|
|
|
|
|
Kiethnt wrote: Sorry I confused some where. so let me post this massage again.
Why don't you modify your previous post?
|
|
|
|
|
try following code.
if( ListBox1.GetCount() > 0 )
{
CString csText;
ListBox1.GetText( 0, csText );
ListBox2.AddString( csText );
ListBox1.DeleteString( 0 );
}
where ListBox1 is the control variable for the listbox 1 and ListBox2 is the control variabale for the listbox 2.
nave
|
|
|
|
|
My program had run already, I really thank for your help Naveen R. However, the problem here is I want the string will be send continuosly when I push Send button once only.
One more question I would like ask you that how to write all string in a Listbox control to file .txt and read string in text file to Listbox control.
Please help me solve this problem.
|
|
|
|
|
CStdioFile File;
File.Open( _T("C:\\listboxdata.dat"), CFile::modeCreate|CFile::modeWrite );
int nCount = m_list.GetCount();
for( int nIdx =0;nIdx< nCount;nIdx++ )
{
CString csText;
m_list.GetText( nIdx, csText );
File.WriteString( csText );
}
File.Close();
Do the reverse for reading...
nave
|
|
|
|