|
Software Zen: delete this;
|
|
|
|
|
Hello,
I need to save a CString in a DLL and I don'r get it to work.
*** Program 1 ***
CString sTest;
sTest = "Hello";
MyDll.Test(sTest);
*** Program 2 ***
OnTimer()
MyDll.Test(Will get the value that program 1 put here )
Byt it dont work I get a int 3 error
If I in Program 2 set a value on the CString then it work but then I don't get the value I need.
*** DLL Class ***
void getFunc( CString sValue )
if(sValue.IsEmty())
{
return;
}
else
{
Do something else!
}
So how can I save A special value from program 1
and check it from program 2?
Please help me.
|
|
|
|
|
Hi larsson
there may be many solution for your problem,but from my knowledge i Know two solution
#1 either declare that variable globlly static in your Dll
or
#2 your have to share them betwwen application
like this
[code]
#pragma data_seg(".SHARDAT")
CString m_strUpdate;
#pragma data_seg()
[/code]
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
|
Hi guys,
I tried to compile and run a #define type templates example code in Visual C++:
#include <iostream>
#define define_max(type) \
type max(type d1, type d2) { \
if (d1 > d2) \
return (d1); \
return (d2); \
}
define_max(int);
define_max(float);
define_max(char);
int main(void)
{
int i = max(100, 800);
char ch = max('A', 'Q');
float f = max(3.5, 8.7);
return 0;
}
and I am getting compile error ambiguous call to overloaded function on the line
float f = max(3.5, 8.7);
If I replace float with double, it will compile and run ok. Does anyone know why that is? Is there some kind of limitation on uses of float in Visual C++?
Thanks alot
|
|
|
|
|
This is just a guess, but try replacing the four occurrences of max() with something like max1() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
3.5 and 8.7 are consider constant doubles.
When I compile the code below, VC gives me a warning for "a" but not for
"b"
float a = 2.4;
warning C4305: 'initializing' : truncation from 'const double' to 'float'
float b = 2.4f;
|
|
|
|
|
vcplusplus wrote:
float a = 2.4;warning C4305: 'initializing' : truncation from 'const double' to 'float'float b = 2.4f;
It makes a difference. I suppose the appended f tells the compiler to treat the numbers as float type?
Thanks.
|
|
|
|
|
Hi,
I have a simple program with a CFrameWnd. I override the OnPaint() function and draw some images. I preload a sequence of images using CxImage (separate objects for each one) and then I use CxImage::Draw() function to draw the particular image one at a time. The problem is that when I change the image being displayed (by changing some pointers to another image and just calling CxImage::Draw() on a different image in OnPaint()) there's a flicker as the images change. It's not that much and when the image is displayed it looks ok, but while the images change there's visible flicker. Is this due to how slow GDI is, or something I'm not doing correctly? The images are 640x480. How do windows that display movies work then (I'm not trying to display movies btw)?
By the way CxImage::Draw() after doing some weird things just calls SetDIBitsToDevice() Win32 function with the bits.
Thanks.
|
|
|
|
|
Budric B. wrote:
The problem is that when I change the image being displayed (by changing some pointers to another image and just calling CxImage::Draw() on a different image in OnPaint()) there's a flicker as the images change. It's not that much and when the image is displayed it looks ok, but while the images change there's visible flicker. Is this due to how slow GDI is, or something I'm not doing correctly?
The flicker comes from automatically erasing the window. That's easily solved. You just have to handle the WM_ERASEBACKGROUND message and return true without erasing.
Nathan Holt
|
|
|
|
|
Thanks. It worked.
But out of curiosity do movie players use GDI? Or do they use OpenGL and write the pixels directly to the graphics card?
|
|
|
|
|
Budric B. wrote:
But out of curiosity do movie players use GDI? Or do they use OpenGL and write the pixels directly to the graphics card?
I believe they use DirectX, which has an intricate set of optomizations. It can give a program direct access to the screen, and I believe it can even set up a hardware pipeline to allow output from a DVD drive to be displayed without any code being executed to draw the video.
Nathan Holt
|
|
|
|
|
How do i change the window shapes to somethiing like ovals. also how do i change the Colors of controols like buttons? i trie using SetBkColor..but i din't work
|
|
|
|
|
this will change the dialog's shape to an oval
CRect rect;
GetClientRect(rect);
m_rgn.CreateEllipticRgn(0, 0, rect.Width(), rect.Height());
SetWindowRgn((HRGN) m_rgn, TRUE);
to change a button's backcolor, if you have a CButton variable assigned to it, it should look something like this: (put this in your dialog's OnCtlColor() message handler).
if(pWnd == (CWnd*)&m_button)
{
pDC->SetBkColor(RGB(0,0,255));
}
[insert witty comment here]
bdiamond
|
|
|
|
|
|
oh, I forgot. You'll have to declare this in your dialog's class definition.
CRgn m_rgn;
[insert witty comment here]
bdiamond
|
|
|
|
|
Hi,
I have an MFC application which gives problems to link (not compile).
I get the following errors:
error LNK2001: unresolved external symbol __imp__floor
error LNK2001: unresolved external symbol __imp__atof
error LNK2001: unresolved external symbol __imp__atof
I ignored the library 'msvcrtd.lib' in my project.
Any ideas how I can solves these two problems?
Greetings,
Jens
|
|
|
|
|
What version of VC++ are you using? Is it a multithreaded project?
Kuphryn
|
|
|
|
|
yes multithreaded debug
(depending on mfc)
|
|
|
|
|
Hi all,
following code produces compiler error
--header1--
template < class T > class myclass{
}
--header2--
class myclass1{
friend class myclass;//<--this line
..
}
This compiles without problems with VS2003, but produce error, that myclass is allready defined as a template with VS2005Express beta1. How should I write? (friend template < class T > class myclass fails too)!
Thanks in advance,
boni
|
|
|
|
|
The code compiles fine in VC++ .NEt 2003.
Try something like on the problematic compiler.
template <typename t="">
class a
{};
class b
{
friend class a;
};
Kuphryn
|
|
|
|
|
greetings
I am really sorry to bother you but i have a slight problem.
i am a university student in England, and i am doing a final year project
called Web based home automation which means i have to control devices over the internet.
the problem is that i have to use borland C++ to write a client/server program to be able to remotely control devices over the internet.
The problem is that i have tried to work with borland C++ version 5.01 but i am unable to do this because, although i know the basics of programming in c,c++,assembly i am someone who is aimed at automation and not really programming.
i basically need to write a simple client/server chat program in c/c++ with borland, and then elaborate on it to enable controlling devices.
please help me, i am really stressed out.
i extremely appreciate any help you can give me!
from Chris
|
|
|
|
|
You got all the way to your final year and have just realised you are not a programmer?
I suggest that you quit and find a different degree to do. Though I would be surprised that you find one where plagiarism is accepted.
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)
|
|
|
|
|
hahaha you're so funny!
1st: who told you thet i was in a programming course?
2nd: its nice to laugh at others problems untill you get one hey?
3rd:plagerism means cheating/copying...i am not asking for someone to write code for me, i just want some advice so if you are too good to help, MIND YOUR OWN BUSINESS!
thanks
|
|
|
|
|
porac69 wrote:
1st: who told you thet i was in a programming course?
You were asking a programming question in a programming forum. It would be easy to assume you are therefore in a programming course.
porac69 wrote:
i am not asking for someone to write code for me, i just want some advice so if you are too good to help, MIND YOUR OWN BUSINESS!
"Please do my homework for me" type requests show up here at least once per week, especially as semesters come to an end. Don't take offense to Antony's comment as it is well-founded. While yours is not the worst by far, students do come here and type in their assignments verbatim and expect to get help.
My first question would by why is using Borland C++ a requirement?
Second, how much help are you expecting to receive from a forum devoted to Microsoft Visual C++? That's not to imply that you won't get help, but just that your chances are less, compared to the help you'd receive from a forum devoted to Borland C++. Make sense?
I put together a very simple server application that listens on port 13. When it gets a request, it sends some text back to the client. I've removed the error checking for brevity.
void main( void )
{
WSADATA wsaData;
int rVal;
char Str[32];
SOCKET client;
WSAStartup(MAKEWORD(1,1), &wsaData);
SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
SOCKADDR_IN sin, clientaddr;
sin.sin_family = PF_INET;
sin.sin_port = htons(13);
sin.sin_addr.s_addr = INADDR_ANY;
rVal = bind(s, (LPSOCKADDR) &sin, sizeof(sin));
rVal = listen(s, 2);
while (1)
{
int addrlen = sizeof(clientaddr);
client = accept(s, (struct sockaddr *) &clientaddr, &addrlen);
if (client < 0)
continue;
char *clienthost = inet_ntoa(clientaddr.sin_addr);
int port = ntohs(clientaddr.sin_port);
fprintf(stderr, "Received request from [%s] on port [%d]\n", clienthost, port);
sprintf(Str, "Hello %s on %d", clienthost, port);
rVal = send(client, Str, lstrlen(Str), 0);
closesocket(client);
fprintf(stderr, "Sent %s to client\n", Str);
}
closesocket(s);
WSACleanup();
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|