|
I tried to create a worker thread. However, I keep get the compile error "error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (__cdecl *)(void)'"
Please help!
many thanks!
p.
//I have a global Thread function:
UINT connection(LPVOID pParam)
{
...
return 1;
}
//Start the worker thread
AfxBeginThread(connection)
{
....
}
|
|
|
|
|
try
AfxBeginThread ( connection , NULL ) ;
the second param is a user data
if u dont need it u can pass NULL
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
What's the rest of the error? It will tell you what the compiler is expecting. You can also put the cursor on AfxBeginThread() and hit F12. This will take you to the function's prototype.
|
|
|
|
|
Weird. Do you have connection() declared in the interface (*.h) file? AfxBeginThread() takes in as parameters more than one or even two.
Kuphryn
|
|
|
|
|
How i do to change the color?
And the Dialog´s color?
|
|
|
|
|
Catch WM_PAINT and/or WM_NCPAINT and paint it yourself.
|
|
|
|
|
(thank you for your fast answer )
Do i have to do with :
<br />
BEGIN_MESSAGE_MAP(TProgressTimeToComplete, CProgressCtrl)<br />
ON_WM_PAINT()<br />
END_MESSAGE_MAP()<br />
???
and then?
|
|
|
|
|
Then you must grab the dc's of the respective wnd's - like this:
(it's the same story in *all* wnd's derived from CWnd - like your ctrl.)
void CMyProgressCtrl::OnNcPaint()
{
// Paint NC-part of window.
CProgressCtrl::OnNcPaint();
// Borrow the dc of the window.
CDC *pdc = GetWindowDC();
if(!pcd)
return;
// Do some stuff ... see below...
// And then release it.
::ReleaseDC(GetSafeHwnd(), (HDC)*pdc);
}
and of more interest to your problem:
void CMyProgressCtrl::OnPaint()
{
// Paint C-part of window.
CProgressCtrl::OnPaint();
CPaintDC dc_paint(this); // Always do this even if you don't want to use it - something interesting goes on in its destructor or something(?).
CDC *pdc = GetDC();
if(!pdc)
return;
CRect irClient;
GetClientRect(irClient);
// Do something...
pdc->Rectangle(0, 0, irClient.Width(), irClient.Height());
}
Good luck!
Regards M.M.
|
|
|
|
|
|
One solution is SendMessage().
SendMessage(hBar, PBM_SETBARCOLOR, 0, reinterpret_cast<lparam>(RGB(255,0,0)));
Kuphryn
|
|
|
|
|
Thanks, but i don´t know in which method i have to call SendMessage (i supouse than OnPaint), and how i get hBar too????????
thanks again
|
|
|
|
|
Hi!
All day I've been fighting with week numbers and their differed definitions (ISO standards). It's rather complicated just from searching the topic on the net! WOW.
I've made this and it SEEMS to work OK in the years arond 2003 - meaning giving the same # as outlook (although not 100% correct in all countries from what I can understand).
#define DAY_SUNDAY 1
#define DAY_MONDAY 2
#define DAY_TUESDAY 3
#define DAY_WEDNESDAY 4
#define DAY_THURSDAY 5
#define DAY_FRIDAY 6
#define DAY_SATURDAY 7
class CTimeEx : public CTime
{
public:
...
inline const int GetWeekNumber()
{
// I THINK this is right
CTimeEx tYearBefore(GetYear() - 1, GetMonth(), GetDay());
int iWeekNumber_OfFirstWeek = 0,
iWeekNumber_OfThisWeek = 0,
iWeeksInYearBefore = tYearBefore.GetWeeksInYear();
const CTimeEx tFirstDayInYear(GetYear(), 1, 1);
// First week containing at least four days is the first week of that year.
const int iDayOfWeekOfFirstDayInYear = tFirstDayInYear.GetDayOfWeek();
if(iDayOfWeekOfFirstDayInYear == DAY_FRIDAY ||
iDayOfWeekOfFirstDayInYear == DAY_SATURDAY ||
iDayOfWeekOfFirstDayInYear == DAY_SUNDAY)
iWeekNumber_OfFirstWeek = iWeeksInYearBefore;
else
iWeekNumber_OfFirstWeek = 1;
iWeekNumber_OfThisWeek = iWeekNumber_OfFirstWeek;
CTimeEx t(tFirstDayInYear);
const CTimeSpan tdOneDay(1, 0, 0, 0);
while(t.GetDayOfWeek() == CTimeEx::GetFirstDayOfWeek())
t += tdOneDay;
const CTimeSpan tDiff = *this - t;
if(tDiff.GetDays() > 0)
iWeekNumber_OfThisWeek = 1 + tDiff.GetDays() / 7;
return iWeekNumber_OfThisWeek;
}
inline const int GetWeeksInYear()
{
// We will always experience a week 53 when December 31st falls on a Thursday, or in the case of a leap year when December 31st falls on either a Thursday or a Friday.
int iWeeksInYear = 52;
CTimeEx tLastDayInYear(GetYear(), 12, 31);
if(IsLeapYear())
{
if(tLastDayInYear.GetDayOfWeek() == DAY_THURSDAY ||
tLastDayInYear.GetDayOfWeek() == DAY_FRIDAY)
iWeeksInYear = 53;
}
else
{
if(tLastDayInYear.GetDayOfWeek() == DAY_THURSDAY)
iWeeksInYear = 53;
}
return iWeeksInYear;
}
inline const bool IsLeapYear()
{ return((GetYear() % 100 == 0) && (GetYear() % 400 != 0)); }
...
};
Regards Michael Mogensen/dk/dev.
|
|
|
|
|
Where GetFirstDayOfWeek() is:
TCHAR szLocalInfo[2];
BOOL bResult = ::GetLocaleInfo(
LOCALE_SYSTEM_DEFAULT,
LOCALE_IFIRSTDAYOFWEEK,
szLocalInfo,
2);
int iFirstDay = _ttoi(szLocalInfo);
SetCyclic(iFirstDay, 2, 1, 7); // Same as ++2 in [1; 7].
return iFirstDay;
|
|
|
|
|
I need to display jpg file on view, pls help
|
|
|
|
|
|
|
If u are using MFC in Visual studio.NET u can use CImage class!!!
Else refer to GDI plus documentation
|
|
|
|
|
Hi ppl
I have written 6 C programs and I now want to make a GUI, I am using Windows API, writing in C, using DEV C++ as compiler running on Windows XP
I have already create da main window and 6 child windows
Actually I want to display the text output of these 6 C programs on the screens of the child windows. And I planned to simply execute the .exe of the C programs in the child windows
But now I got the problem that I cannot simply execute the C programs in the child windows as I want to display the outputs to the child windows, I have to make a communication between the C program and the child window in the GUI program
As I said I created 6 child windows, each of them are for a particular
C program that I mentioned above. So for like I have program A B C D E F, and child windows A B C D E F. Then the outputs of program A will be displayed in child window A, and then program B for child window B...etc.
These 6 programs are actually written to be run in UNIX environment, it's just I think I should make a nice looking little application window to group these 6 windows. And I don't want console windows...black and grey. And so actually these 6 C programs are very much about text input and output. And to be precise, 5 of them only have outputs and only one has input, and it's like this
printf("Please enter input\n");
getchar();
So I don't even have to monitor the input like mouse input in many of the application windows, I know when to get input.
So my question is how do I make the C programs to communicate with the GUI program so that the outputs will be displayed on the child windows and get the input from the child windows.
Very desparate for some help here. Hope u guyz can give me some hints. =)
Thank you very much!!
Franky
fRaNkLy i'm FrAnKy
|
|
|
|
|
You'll want to create the processes with CreateProcess(). Then you'll want to read what is written to the STARTUPINFO.hStdOutput handle.
See if MSDN article Q190351 helps.
|
|
|
|
|
Sorry to ask anothe stupid question, but can you give me the link? Bcoz I searched from google "msdn article Q190351" but couldn't find it...
Thanz
fRaNkLy i'm FrAnKy
[edit]
Oh sorry...hehe...I got it now...me looking at it now
Thanz really!!
|
|
|
|
|
|
Oh so is that I will use that standard input and output handles in the Windows API program? Bcoz I see both of the programs there in the source codes are main(), so I am not sure if it is redirecting the I/Os from console to the windows API.
Actually I'm quite new to windows API, so plz forgive my ignorance if I have asked some very dumb questions.
Thanz
fRaNkLy i'm FrAnKy
|
|
|
|
|
OK...I think I have resorted to use a individual window for a program
I mean one window application for one console program...
But I still have problems even making that....how do I ouput the text?
I know I have to use the function TextOut but ...should I simply replace all the "printf" with "TextOut" or there is extra workings?
Thanz!!
fRaNkLy i'm FrAnKy
|
|
|
|
|
Anyone got any idea of how to group these windows together? Like the "tile" action of the window or sth...I really want to group the 6 windows...at least closer I mean...it's really ugly and messy to have 6 console windows spreading all over the screen....
Thanz really!!
fRaNkLy i'm FrAnKy
|
|
|
|
|
How would one add unicode support to a text editor control that uses CString for a buffer?
Would the control already have implicit unicode support?
GDI functions like DrawText() will automatically be converted to DrawTextW or DrawTextA depening on _UNICODE define???
I've never bothered much with unicode and figure i should start
Thanks
"Two wrongs don't make a right, but three lefts do!" - Alex Barylski
|
|
|
|