|
The last line in your code
pFont->DeleteObject() is deleting the font you just created. That causes Windows to draw the text using the default font.
Software Zen: delete this;
|
|
|
|
|
hi any body can give me some client server application examples for serial port communication in VC++. My requirement is server will be always listening on the serial port for receing the messages from client. client only will send messages to the server.
Pls help me in this regard, it's kinda urgent..
thanks in advance..
|
|
|
|
|
Hi,
Can anybody let me know the conversion function/method which will convert the TCHAR* to numeric (int/decimal).
Actually I fetch the values from the database, bind it to an two dimentional array of type TCHAR. The values will look something like this.
Value in database column is 100000 (numeric).
TCHAR colNameArray[256][256];
I bind the database column to array colNameArray. And the value appears like this as given below.
colNameArray[0][0] = 160
colNameArray[0][1] = 134
colNameArray[0][2] = 1
colNameArray[0][3] = 0
Which is actually 160 + 134*(256) + 1*(256^2) = 100000.
I am looking for some method which would take colNameArray as input as convert to to a string (ascii) or to integer or to numeric.
Converting to string is quite ok, so that I could convert to appropriate data types later.
Thanks in advance.
Prashant.
|
|
|
|
|
TCHAR is defined as
<br />
typedef wchar_t TCHAR;<br />
so you can use the function below including <stdlib.h>
<br />
long _wtol(<br />
const wchar_t *string <br />
);<br />
don't understand what you doo below, hope I helped you
|
|
|
|
|
Yes I could have used _wtol if I was able to read the number as a string, but I am not able to see the number as string as explained in my question above.
So I am actually looking for a method to first convert the value to string or w_string then go on to convert to numeric.
- Prashant
|
|
|
|
|
How about:
x = colNameArray[0][0] + colNameArray[0][1]*256 + colNameArray[0][2]*65536 + colNameArray[0][3]*16777216;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
This works fine for an integer, thats true.
But I could as well get a float/double, date-time, etc. So I was looking for some method which would convert this data to a string (ASCII). Later using atol, atof etc I could convert to the appropriate data type.
Thanks
|
|
|
|
|
I mostly understand what you are asking for, but I'm not sure we are yet on the same page. By using a TCHAR array, the values stored in that array can range from -128 to 127. The 160 and 134 you have stored in there now won't work unless you change the type to be TBYTE instead. TBYTE works with values from 0 to 255.
PrashantJ wrote:
But I could as well get a float/double, date-time, etc.
You would not be able to store 12.34 into a type TCHAR or TBYTE .
Out of curosity, since the database column is numeric, why not bind it to a numeric type?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello,
I only have two quick questions to ask you and they are:
- Can one implement DLLs in VC with MFC support?
- How does one do about retrieving the taskbar window handle (HWND or CWnd )?
Thanks a lot,
David
|
|
|
|
|
How does one do about retrieving the taskbar window handle (HWND or CWnd)?
HWND hTaskBar = FindWindow("Shell_TrayWnd", NULL);
I am not sure about first question, I think you can probably do it!
ARSALAN MALIK
|
|
|
|
|
dNimrod#X wrote:
Can one implement DLLs in VC with MFC support?
Yes. Remember that DLLs existed long before MFC came about.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
That's great!
By the way, will I have to take special care about any particular issue(s) related to developing a DLL with MFC support?
David
|
|
|
|
|
With AppWizard, you can create two types of DLL projects: MFC and Win32. With MFC, you can create a:
regular DLL with MFC statically linked
regular DLL with shared MFC DLL
MFC extension DLL.
Search MSDN for examples of each.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yeah, I've done that so far. My question had to do more with issues such as:
- function declaration;
- does MFC act differently when running from a DLL?
- will I have to use CProcessLocal<CMyGlobalData> globalData (i.e.) to handle dynamic data? And if so, how/when should I use it?
I have done a couple of DLLs before, but none had MFC support, so I'm a bit lost out here. I really have no idea how MFC behaves when running from a DLL...
Thanks for your patience though! : )
Dave Nimrod
|
|
|
|
|
dNimrod#X wrote:
function declaration;
Functions are declared the same no matter where they reside. One difference is that exported functions must use __declspec(dllexport) if they are going to be used by other EXEs and DLLs.
dNimrod#X wrote:
does MFC act differently when running from a DLL?
No, but there are precautions that must be taken. For instance, if a function within the DLL will be using a resource that is also contained within the DLL, a call to AFX_MANAGE_STATE() will be required so that the DLL's resource table is looked at rather than the EXE's.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks for the invaluable input!
You have been really helpful.
Dave
|
|
|
|
|
Hi all
I created a windows service that runs fine on windows 2000,xp and 98.
It runs fine on NT but I get a error dialog whenever I try to logoff,restart or shutdown my computer, keeping the service running. This dialog box appears twice, each time I have to press EndTask.
There is no problem if I shutdown my service and then logoff,restart or shutdown my computer.
Any Idea what could be wrong.?
This problem does not arise if I doesnt allow my serice to interact with the desktop. But that is not a solution.
Thanks in advance.
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hey, here is my code.
Player::Player( char pName[20] )<br />
{<br />
playerName = pName;<br />
isWon = false;<br />
winsCount = 0;<br />
}
I got the error from this part;
error C2440: '=' : cannot convert from 'char []' to 'char [20]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
playerName is decleared as
char playerName[20] in header file.
Regards,
-
When in doubt, push a pawn!
-
|
|
|
|
|
use strcpy() function to copy array. You can't do it like this.
strcpy(playerName, pName);
It will work
Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth!
-Fyodor Dostoevsky, The Brothers Karamazov
|
|
|
|
|
in this case BugSearcher is right, since arrays have the same size, in general case, you should use
<br />
strncpy(dest,src,number_bytes_to_be_copied);<br />
in order to avoid buffer-overflow
P.S. BugSearcher, I've found a bug in your code
|
|
|
|
|
Thanks both of you.
However, I got warning this time
Warning C4996: 'strcpy' was declared deprecated
c:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(62) : see declaration of 'strcpy'
Isn't there any method that returns nothing? or using in this way is better?
Regards,
-
When in doubt, push a pawn!
-
|
|
|
|
|
HI
i have a problem that i can not cast a Cbitmap to HBITMAP to have a CWND handle. the code below should show my created Bitmap. Please
need a TIP......................!!!!!!!!!!!!
CBitmap pic1;
pic1.CreateBitmap( nWidth, nHeight, nPlanes, nBitCount, lpstr);
pic1.Attach(HBITMAP(pic1));//????????????????????????????????
BITMAP bild_header1;
pic1.GetBitmap(&bild_header1);
CWnd* wp1 = GetDlgItem( IDC_STATIC3);// IDC_STATIC_CAM1
CDC *pDC1 = wp1->GetDC();
CDC imageDC1;
imageDC1.CreateCompatibleDC(pDC1);
imageDC1.SelectObject(&pic1);
pDC1->BitBlt(0,0,bild_header1.bmWidth,bild_header1.bmHeight,&imageDC1,0,0,SRCCOPY);
imageDC1.DeleteDC();
|
|
|
|
|
You don't need to Attach , once bitmap is created. So remove the line, it should work!
ARSALAN MALIK
|
|
|
|
|
Thank you for y answer, have tryed it without attach before but its not running.
Even i need this attach because its necessary to display in the CWND.
So i need some how a HBITMAP and then need to attach it.
Actually the code running well when i am loading bitmap. But not in the way i have done now. I really stuck!"!!!!!!!!!!!
|
|
|
|
|
Hi
have solved the problem
with
CreateDIBitmap
bye
|
|
|
|