|
You need to send the handle of the dialog to the thread because all thes window funcs come in two forms:
The global:
::SetDlgItemText(HWND, IDC_Blue, Blue);
And the Class Specific:
myDlgItem->SetDlgItemText(IDC_Blue, Blue); or
this->SetDlgItemText(IDC_Blue, Blue);
'this' is of course given for free if you are inside the actually controls class so you can write:
SetDlgItemText(IDC_Blue, Blue);
So, you are in a thread, NOT in the MFC class instance, so you need to pass the window handle to the thread in order to manipulate it there.
Or even better create your own messaging system so you can send a message to the main window thread from your thread so the main window thread can do all the detailed work rathert than having to code it in your worker thread.
|
|
|
|
|
thank you everyone..that was really helpful.
thanks again.
|
|
|
|
|
Hi,
SockCleintThread is a derived class from base Class CWinThread
so <pre lang='cpp'> CWinThread* current;
dynamic_cast<SockCLeintThread*>(current)= AfxGetThread(); </pre>
in fact the compiler is telling me to do what I am doing
why is it flagging the statement as a error
SockCLient.cpp(12) : error C2440: '=' : cannot convert from 'CWinThread *' to 'SockCLeintThread *'
1> Cast from base to derived requires dynamic_cast or static_cast
|
|
|
|
|
I guess the cast should be like this -
SockCLeintThread* current = dynamic_cast<SockCLeintThread*>(AfxGetThread());
|
|
|
|
|
I don't think you can cast the LHS of an expression. It should be:
SockCLeintThread* current = dynamic_cast<SockCLeintThread*>(AfxGetThread());
AfxGetThread() returns a CWinThread* by default, so you need to cast that to the actual type that will be returned when storing it in your thread pointer. If you define current as a CWinThread* then you will not be able to use it as a SockCLeintThread* anywhere following.
|
|
|
|
|
CWinThread* current = (CWinThread*)AfxGetThread();
That's the simplest coding, using the C cast. But see what you are doing? You are casting AfxGetThread() to a CWinThread type.
So in C++:
CWinThread* current = dynamic_cast<cwinthread*>AfxGetThread();
|
|
|
|
|
Hi
I have downloaded aarot.zip and trying to understand the code. Bcoz i need to implement that on embedded programming.
But the API used here is not known to me.
So can anyone help me to understand the code.
AND IF POSSIBLE
Plz help me to know source code of the functions SetDIBits and GetDIBits. How it is working.
Thanks
|
|
|
|
|
If you are talking about an article here on Code Project, you'll have much better luck if you post your question at the end of the article.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I can also manage if I have the code for the body of SetDIBits function.
|
|
|
|
|
Documentation for all Windows API functions can be found quite easily on MSDN[^].
|
|
|
|
|
Hi,
I am using both derived CwinApp and CFrameWnd as Anchor point for pointers to other objects such derived Cwinthreads
e.g. I created the threads which I have socket classes in them in the INITINSTANCE of the Derived CwinApp
Later in the derived modal and modless dialog box code I refer to these pointers
Instead of inluding the header file for the main window and app in each .cpp file
woud precompiling these and headers and using the precompiled header option be a better option
Thanks
|
|
|
|
|
if they aren't going to change often and many files need them, then sure.
|
|
|
|
|
I always turn off pre-compiled headers.
I would rather spend a couple extra seconds on a compile versus trying to figure out why code that I can see with my own eyes obviously isn't running (because it didn't recompile.)
|
|
|
|
|
Dear All,
I have problem, please help me!
I write a program about authentication fingerprint.
For example, cursor is on notepad window or on textbox of any program, If the authentication process is right, I want to display "Yes" characters to position where cursor is blinking. If display at textbox of this program, this process is easy. However, I want to display at textbox of other program as skype program, google chrome program or notepad program.
Thank about help!
Kelvin Nguyen
|
|
|
|
|
I all
I have a site using mysql and php accessing just for select data ...
And i have a win32 app in local machine ...
I want to use de win32 to update, insert e select into to site db
How can i do this ?
sorry by the poor english ....
thanks for any help ...
Samuel / Brazil
|
|
|
|
|
|
Plz any body can help me to do a binary value division
|
|
|
|
|
All of these questions can be answered by reading the language references here[^].
|
|
|
|
|
#include <stdio.h>
#include <stdlib.h>
void load(int*, int*, int*);
void display(int*, int*, int*);
void compute(int*, int*, int*);
void adder(int*, int*);
void negate(int*);
void main()
{
int i;
int DIVISOR [5];
int REMAINDER [5];
int DIV_QUOT [4];
load(DIVISOR, REMAINDER, DIV_QUOT);
printf(" DIVISOR |\t REMAINDER\t DIVIDEND/QUOTIENT");
printf("\n --------|----------------");
printf("---------------------------\n");
display(DIVISOR, REMAINDER, DIV_QUOT);
printf("\n --------|----------------");
printf("---------------------------\n");
for (i=0; i<4; i++)
{
compute(DIVISOR, REMAINDER, DIV_QUOT);
printf("\n --------|----------------");
printf("---------------------------\n");
}
}
void compute(int DIVISOR[], int REMAINDER[], int DIV_QUOT[])
{
int DIVISOR_Copy [5];
bool neg;
REMAINDER[1] = REMAINDER[2];
REMAINDER[2] = REMAINDER[3];
REMAINDER[3] = REMAINDER[4];
REMAINDER[4] = DIV_QUOT[0];
DIV_QUOT[0] = DIV_QUOT[1];
DIV_QUOT[1] = DIV_QUOT[2];
DIV_QUOT[2] = DIV_QUOT[3];
DIV_QUOT[3] = 888;
display(DIVISOR, REMAINDER, DIV_QUOT);
printf(" | <--- Shifting left...\n");
DIVISOR_Copy[0] = DIVISOR[0];
DIVISOR_Copy[1] = DIVISOR[1];
DIVISOR_Copy[2] = DIVISOR[2];
DIVISOR_Copy[3] = DIVISOR[3];
DIVISOR_Copy[4] = DIVISOR[4];
negate(DIVISOR_Copy);
adder(REMAINDER, DIVISOR_Copy);
if (REMAINDER[0] == 1)
neg = 1; else
neg = 0;
display(DIVISOR, REMAINDER, DIV_QUOT);
if (neg)
{
adder(REMAINDER, DIVISOR);
DIV_QUOT[3] = 0;
printf(" | NEGATIVE. ? = 0\n");
}
else
{
DIV_QUOT[3] = 1;
printf(" | POSITIVE. ? = 1\n");
}
display(DIVISOR, REMAINDER, DIV_QUOT);
}
void negate(int A[])
{
int i;
int ONE[5];
ONE[0] = 0;
ONE[1] = 0;
ONE[2] = 0;
ONE[3] = 0;
ONE[4] = 1;
for (i=0; i<=4; i++)
{
if(A[i] == 1)
A[i] = 0;
else
A[i] = 1;
}
adder(A, ONE);
}
void adder(int A[], int B[])
{
int next, i, carry=0;
for (i=4; i>=0; i--)
{
next = 1;
if (A[i]==0 && B[i]==0)
{
A[i]= carry;
carry = 0;
next = 0;
}
if (next)
if (A[i]==0 && B[i]==1)
{
if (carry == 0)
A[i] =1;
else
A[i]=0;
next = 0;
}
if(next)
if (A[i]==1 && B[i]==0)
{
if (carry == 0)
A[i] =1;
else
A[i]=0;
next = 0;
}
if(next)
if (A[i]==1 && B[i]==1)
{
if (carry == 0)
{
A[i] =0;
carry = 1;
}
else
A[i]=1;
next = 0;
}
}
}
void display(int A[], int B[], int C[])
{
int i;
printf(" ");
for(i=1; i<=4; i++)
printf(" %d", A[i]);
printf(" | ");
for(i=1; i<=4; i++)
printf(" %d", B[i]);
printf(" ");
for(i=0; i<=3; i++)
if ((C[i] == 0) || (C[i] == 1))
printf(" %d", C[i]);
else
printf(" ?");
}
void load(int A[], int B[], int C[])
{
A[0] = 0;
A[1] = 1;
A[2] = 0;
A[3] = 0;
A[4] = 0;
B[0] = 0;
B[1] = 0;
B[2] = 0;
B[3] = 0;
B[4] = 0;
C[0] = 1;
C[1] = 0;
C[2] = 0;
C[3] = 0;
}
|
|
|
|
|
Any body Can tell me logic gate function in binary value in C3
|
|
|
|
|
You wanna modify your title of this thread because your other thread has the EXACT same title, do it before the moderators or admin takes some hard action against you.
But anyways, a Google(R) search here may give the answer, I mean hey Google may suck from time to time, but why not give it a try? your be surprised what you may find, try looking on the other pages except the first page of results.
Simple Thanks and Regards,
Brandon T. H.
Programming in C and C++ now, now developing applications, services and drivers (and maybe some kernel modules...psst kernel-mode drivers...psst).
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
|
plz any one can send me logic gates in C#
|
|
|
|
|
|
I need ftp C/C++ functions/classes to process ftp uploading/downloading tasks.
When I used software [FileZilla FTP Client], it sends/obtains many interesting events/messages, such as:
Status: Resolving address of www.xyz.com
Status: Connecting to 11.222.333.444:21...
Status: Connection established, waiting for welcome message...
Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
Response: 220-You are user number 3 of 1000 allowed.
Response: 220-Local time is now 15:16. Server port: 21.
Response: 220-This is a private system - No anonymous login
Response: 220-IPv6 connections are also welcome on this server.
Response: 220 You will be disconnected after 15 minutes of inactivity.
Command: USER xyz
Response: 331 User xyz OK. Password required
Command: PASS *****************
Response: 230 OK. Current restricted directory is /
Command: SYST
Response: 215 UNIX Type: L8
Command: FEAT
Response: 211-Extensions supported:
Response: EPRT
Response: IDLE
Response: MDTM
Response: SIZE
Response: REST STREAM
Response: MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
Response: MLSD
Response: AUTH TLS
Response: PBSZ
Response: PROT
Response: ESTA
Response: PASV
Response: EPSV
Response: SPSV
Response: ESTP
Response: 211 End.
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/" is your current location
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
Command: PASV
Response: 227 Entering Passive Mode (74,220,215,241,4,101)
Command: MLSD
Response: 150 Accepted data connection
Response: 226-Options: -a -l
Response: 226 33 matches total
Status: Directory listing successful
(many more ...)
Those events are very useful and in details, I think MFC FTP classes are NOT powerful enough to process them.
What FTP C/C++ functions/classes are used by [FileZilla FTP Client] (or better than them)? I'd like to try them.
Thanks for links and comments.
.
|
|
|
|
|