|
::LoadImage
::PlaySound
I'm not joking.
If you want to load something that's not a bmp, you need to either use GDI+ ( built in if you have VS.NET 2002 or 2003, even if you're not using managed code ). My articles explain how to use it, and how to set it up if you're stuck in VC6.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is there a way/method to modify the current date value so that it will end up become the last day of the next month in c runtime library?
e.g.
Lets say date is 15/05/2005. After modification, it should become 30/06/2005 and then 31/07/2005 and so on.
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
Could you be more specific? Is it the system's time that you are trying to change? Or is it a file's or folder's access/creation/modification time that you are trying to change? Also, I would suggest that you take a look at time.h which is the a standard C library with date and time related functions. difftime function might be useful to you, and also the tm structure.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Actually, the standard file is called ctime. all C++ headers dropped the h when they were standardised ( i.e. iostream, not iostream.h ) and additionally, a C was prepended for the C runtime files ( so ctime, not time.h ).
The old ones are there for compatibility only, although in reality, because most people still use them, they are probably there to stay.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Technically yes, but the question mentioned C, not C++...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Well, i am using time_t and localtime(...).
time_t tDateTime;
time(&tDateTime);
tm *pstTM = localtime(&tDateTime); Base on the current date i got, i need to derive the date of the end of following month. I know i can modify the tm_mon and tm_mday values in the tm structure, then use mktime to get the new date but it is not accurate as each month has different number of days.
Toni78 wrote:
difftime function might be useful to you
I dont really need to find the difference. I just need to get the end date
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
Weiye Chen wrote:
i need to derive the date of the end of following month
For that,You have to derive your own LOGIC. here is small piece of code to get started.
time_t tDateTime;
struct tm *pstTM,endDate;
int isLeap;
time(&tDateTime);
pstTM= localtime(&tDateTime);
printf("\nToday-%d/%d/%d",pstTM->tm_mday,pstTM->tm_mon+1,pstTM->tm_year+1900);
if(pstTM->tm_year%4)
isLeap=1;
else
isLeap=0;
endDate=*pstTM;
if(endDate.tm_mon==1)
{
if(isLeap)
endDate.tm_mday=29;
else
endDate.tm_mday=28;
}
else
{
if(((!(pstTM->tm_mon%2))&&(pstTM->tm_mon<=6))
||((pstTM->tm_mon%2))&&(pstTM->tm_mon<code>>=</code>7))
endDate.tm_mday=31;
else
endDate.tm_mday=30;
}
printf("\nModified Date: %d/%d/%d"
,endDate.tm_mday,endDate.tm_mon+1,endDate.tm_year+1900);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Thanks alot man.
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
There is a small mistake in code,I have modified it and marked it with bold character
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
If you are into Boost then I suggest you use boost:date which uses ISO 8601. See: http://www.boost.org/doc/html/date_time.html and http://www.cl.cam.ac.uk/~mgk25/iso-time.html
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Weiye Chen wrote:
I dont really need to find the difference. I just need to get the end date
ThatsAlok gave you the perfect answer, but difftime could be very useful when you want to jump from one time period to another. I used to use it a lot when I was writing software for room bookings.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
About two hours ago I came up with the brilliant idea to create a console app that will compare files and their attributes. I got the psedocode all mapped out and then wondered how i'd get the "dir" command to run from the command line executed from within my code. I've heard of a GetCommandLine function, but I can't seem to find enough on it, such as what types of arguments it accepts and what .lib and header files to link and include. If you know of any good links or have a remedy to my problem it would be appreciated.
:->
|
|
|
|
|
This is where you can get more information [^]" >
You have to parse the strings to get the "dir" command.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
This is my MFC dialog project.
Im working on code to change my systray clock color to some colors.
both background and text to different color.
take a look at my code.
void CStart_Button_ChangerDlg::OnClock()
{
RECT rc;
HWND hWnd = ::FindWindow("Shell_TrayWnd", NULL);
if (hWnd) {
if (NULL != (hWnd = ::FindWindowEx(hWnd, NULL, "TrayNotifyWnd", NULL))) {
if (NULL != (hWnd = ::FindWindowEx(hWnd, NULL, "TrayClockWClass", NULL))) {
//::SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)(LPTSTR) TEXT("TEST") );
HDC hdcClock;
COLORREF col;
HDC hdc;
char s[1024];
if(hdcClock) DeleteDC(hdcClock); hdcClock = NULL;
//if(bFillTray)
hWnd = ::GetParent(hWnd);
::GetClientRect(hWnd, &rc);
hdc = ::GetDC(NULL);
hdcClock = CreateCompatibleDC(hdc);
if(!hdcClock)
{
::ReleaseDC(NULL, hdc);
return;
}
//SelectObject(hdcClock, hFon);
SetBkColor(hdcClock, RGB(0,0,255));
SetBkMode(hdcClock, TRANSPARENT);
SetTextAlign(hdcClock, TA_CENTER|TA_TOP);
SetTextColor(hdcClock, RGB(0,255,255));
//FillClock(hWnd, hdcClock, &rc, 0);
HBRUSH hbr;
HDC hdcTemp;
int nblink;
RECT *prc;
if(nblink == 0 || (nblink % 2)) col = RGB(255,255,0);
else col = RGB(255,0,0);
//if(col & 0x80000000) col = GetSysColor(col & 0x00ffffff);
//SetBkMode(hdc, OPAQUE);
//SetBkColor(hdc, col);
hbr = CreateSolidBrush(col);
FillRect(hdc, prc, hbr);
DeleteObject(hbr);
::ReleaseDC(NULL, hdc);
MessageBox("TEST PASSED");
}
}
}
|
|
|
|
|
I put this code in a project and compiled it. Do you ignore warnings, or are they turned off ?
HDC hdcClock;
COLORREF col;
HDC hdc;
char s[1024];
if(hdcClock) DeleteDC(hdcClock); hdcClock = NULL;
You do not set hdcClock to NULL when you create it, and you never set it to anything else before trying to delete it. It's not NULL, and so it will try to delete it, but it won't point to anything valid.
int nblink;
RECT *prc;
if(nblink == 0 || (nblink % 2)) col = RGB(255,255,0);
nblink, same problem.
RECT *prc;
if(nblink == 0 || (nblink % 2)) col = RGB(255,255,0);
else col = RGB(255,0,0);
//if(col & 0x80000000) col = GetSysColor(col & 0x00ffffff);
//SetBkMode(hdc, OPAQUE);
//SetBkColor(hdc, col);
hbr = CreateSolidBrush(col);
FillRect(hdc, prc, hbr);
same problem - prc.
NEVER create a variable without initialising it's value. And goodness knows what half this code was trying to do, I assume you found an online sample and deleted half the code ?
Also, you should step through the debugger first, before asking for help. If you do that, you may solve the problem and you'll at least be able to tell us the line that blows up, and the error you get ( actually, you should have been able to tell us the error anyhow ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
my program is a dialog based one ,and i called AfxSocketInit(NULL) successfully!
but a error occured when program run to mysocket.create() in my thread function(debug assertion failed )
who can tell me what's the posible problem
thanks
|
|
|
|
|
Did you call AfxSocketInit(NULL) in your thread?
John
|
|
|
|
|
i did .i call AfxSocketInit(NULL) in main thread (in mydialog::OnInitDialog())
and CSocket is a work thread variable
UINT DoScan(LPVOID lppara)
{
.............
CSocket scansocket;
scansocket.Create(); /////////error occur when running
.............
}
|
|
|
|
|
rtfm - what parameters does CSocket::Create(...) require - i.e. none - now have a look at what creating a TCP/IP or indeed any other type of socket actually requires.
CSocket() is almost a non-sequiteur.
|
|
|
|
|
i call create() with no parameter ,this can work
the error is run-time error
|
|
|
|
|
Hello !
I don't have a lot of experience with GDI... So here is my question: I have wo Device contexts, the source and the destination. In the destination, there is already some drawing. Now, I want to paste my source DC (which contains a bitmap) over the desination DC but using a transparent blitting, that is the background color of the source must not be copied (and the other colors must be kept like they are, so not using bitwise operators).
Is such a thing possible ? If yes, how to do that ?
Thanks
|
|
|
|
|
|
|
Hi !
Thanks for the response but I have a linker error: error LNK2001: unresolved external symbol __imp__TransparentBlt@44.
And also, I am using MFC objects (CDC, CBitmap, ...) and this function is not defined in the CDC class. So maybe it can lead to problems if I mix CDC with HDC...
|
|
|
|
|
cedric moonen wrote:
Thanks for the response but I have a linker error: error LNK2001: unresolved external symbol __imp__TransparentBlt@44.
That means you are not linking to the right library for this function. Do you have VC7, or if you're using VC6, do you have a platoform SDK installed apart from the one that came with it ( you must do, otherwise you wouldn't get to the linking stage ). If the latter, perhaps your lib directory is not set up, but your include directory is.
cedric moonen wrote:
So maybe it can lead to problems if I mix CDC with HDC...
No - a CDC is just a wrapper around a HDC, they boil down to the same thing with some helper functions. TransparentBlt is not supported by W95, and VC6 did not come with TransparentBlt, etc, because they did not exist. therefore, VC6 users need to have a more recent platform SDK installed in order for the compiler to know how to call those functions. It sounds like your compiler can find the header files that define this function, but not the lib file required at linking time, therefore I think you have VC6 and a Platform SDK that is not installed properly.
And obviously, if you use TransparentBlt, your exe won't run on W95. If it needs to, I wrote a W95 compatible version of TransparentBlt and AlphaBlend years ago, it's hosted on the Windows Developer Journal site. If you google 'Graus AlphaBlend TransparentBlt', you're bound to find it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|