|
I just can't see why the following code doesn't change the text color to red.
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc = ::GetDC(hwnd);
HPEN pen = ::CreatePen(PS_SOLID, 3, RGB(255, 0, 0));
HGDIOBJ old;
old = ::SelectObject(&hdc, pen);
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
case WM_LBUTTONDOWN:
::TextOut(hdc, 100, 100, TEXT("Hello Windows"), 13);
::SelectObject(hdc, old);
return 0;
}
ReleaseDC (hwnd, hdc) ;
return ::DefWindowProc (hwnd, message, wParam, lParam) ;
}
//////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("RegisterClass Fail!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
HWND hwnd ;
hwnd = CreateWindow (szAppName,
TEXT ("The Hello Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
MSG msg ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
|
|
|
|
|
for change color text you can use
SetTextColor(hdc,RGB(255,0,0));
whitesky
|
|
|
|
|
As WhiteSky implied, pens don't change the text colour. They change the colour when drawing lines, circles etc...
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"
|
|
|
|
|
Hi,
I have following case,
I want to put some static text on toolbar.For that i am using SetButtonInfo function with some ID as a placeholder and setting width of button. using function,
m_wndToolBar.SetButtonInfo(10, ID_PLACEHOLDER1, TBBS_SEPARATOR, width);
and creating Control using ID_PLACEHOLDER1 as a paremeter.
In these case, the rectangle bouning the text is of some size say x. with a vertical seperator in the middle of text.
Now if i use
m_wndToolBar.SetButtonInfo(10, ID_PLACEHOLDER1, TBBS_BUTTON, width);
the width parameter has no effect and bounding rectangle is also of different size. but in these case there is no vertical seperator.
Can someone point me how i can remove the seperator and how to use SetButtonInfo function in a proper way.
Thanks in advance.
Regards
Abhi Lahare
|
|
|
|
|
error C2859...
how can I repair it&
|
|
|
|
|
|
Try turning off incremental builds and do a rebuild all.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Hmm. I think I must be overworking again...
Steve S
Developer for hire
|
|
|
|
|
Steve S wrote: Hmm. I think I must be overworking again...
I've worked for 1 company that required more than 40 (uncompensated) hours a week (usually ended up being 50-60). Since then, I only work 40+ if I'm being compensated for it in some fashion.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi All,
I am using directshow api to convert jpg files to video files.
when i try with more than three images it fails. How do i set media times. I am not including any transition effects here.
Thanks in Advance
Poornima
|
|
|
|
|
Hi,
I have built an win32 applicaion in which i m using global functions n no classes. I want to open a CFileDialog in the applicaion but i m not able to get CWnd *m_pMainWnd member of the application, which is required to initialize CFileDialog object.
When in Winmain function of my application I write this
/////////////////////////////////////////////////
CWinApp* app=AfxGetApp();
ASSERT(app!=NULL); // app is NULL when I check in Debug window
pWnd=app->m_pMainWnd; // CWnd *pWnd , global variable
//////////////////////////////////////////////////////////////////////
It generates a Debug Assertion Failed message.
Can any one suggest a solution.
I need the CWnd variable for CFileDialg in function and want to pass it to the function instead fo HWND hWnd.
/////////////////////////////////////////////////////////////////////////////
void LoadXmlFile(HWND hWnd)
{
CString strFileName;
char szFilters[]= "XML Files (*.xml)|*.xml";
CString str;
CFileDialog fileDlg(true,0,0,OFN_FILEMUSTEXIST| READONLY,szFilters ,(CWnd*)hWnd );
.....................
}
//////////////////////////////////////////////////////////////////////
I ll appreciate if anyone helps.
Thanx in anticipation.
Cyber Friend
|
|
|
|
|
Cyber Friend wrote: I have built an win32 applicaion in which i m using global functions n no classes
That implies that you are not using MFC, so there will be no CWinApp instantiated in any of your address space. This will also make it tough to implement or use any other MFC based classes. The best alternative I can offer is to look up about the OPENFILENAME struct and the functions GetOpenFileName and GetSaveFileName and use them instead.
Chris Meech
I am Canadian. [heard in a local bar]
The America I believe in has always understood that natural harmony is only one meal away from monkey burgers. [Stan Shannon]
GOOD DAY FOR: Bean counters, as the Australian Taxation Office said that prostitutes and strippers could claim tax deductions for adult toys and sexy lingerie. [Associated Press]
|
|
|
|
|
|
|
In the WinMain function you should use:
<code>AfxSetResourceHandle</code>(hInstance);
CWinApp *pTheApp = new CWinApp; after the InitInstance call and
delete pTheApp; after the message loop.
Avoid doing it with the MFC once you have started in the plain API mood.
"quot capita, tot sententiæ"
rechi+
|
|
|
|
|
First, you must decide if you want to use MFC, or if you do not want to use it.
If you are going to use it, derive a class from CWinApp. Override InitInstance (and any other methods you care to) and create a main window there (and assign it to the m_pMainWnd pointer). By default, CWinApp does not have/create a window for you, so the code you are doing above will not work because m_pMainWnd is NULL. This is desired behavior because you can use CWinApp to create a class for console apps.
If you are not going to use MFC, you need to use the Win32 APIs to initialize and create the dialog. There are some documents in MSDN that should get you started.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thanx to all of you for ur nice suggestions. I have solved this problem wid the help of a person.
Solution is :
I added this
AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
to Winmain() of my Win32 application n then got CWnd* like this
CWnd* pParentWnd = CWnd::FromHandle(hWnd);
and then passed thi pParentWnd to CFileDialog's constructor n then all worked correctly.
Regards
Cyber Friend
|
|
|
|
|
I'm hanving problems with digest authentication with Microsoft-IIS/5.0
server , does any one have solution for plz ,
i'm waiting ...
|
|
|
|
|
HI,
I want to Minimze the Application to System Tray at click on Close (Crosss) button, I dont want to get it closed on clickking on Close button
Where I can capture the click envent on close button.
How ca I minimize application to system tray.
Regards.
|
|
|
|
|
Handle the WM_CLOSE message..
If ur using a dialog based application u can overide OnClose() function
nave
|
|
|
|
|
|
zahid_ash wrote: I want to Minimze the Application to System Tray at click on Close (Crosss) button, I dont want to get it closed on clickking on Close button
Where I can capture the click envent on close button.
How ca I minimize application to system tray.
WM_SYSCOMMAND for ALT+f4 too!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Help CRY
|
|
|
|
|
Where the WINDOWS stores information about arranging (sorting) order in folders that was assigned in Shell Browser. How to determine or assign new arranging order by using shell functions or other methods. This task in undocumented, but the Shell Browser can do this..
I will be thankful for any information about this. Thank you.
|
|
|
|
|
|
I have Bytes in the following variable "resultArray"
byte resultArray __gc[] = new byte __gc[1];
I need to Take string from this variable with ASCII encoding.
For reference in C# we will do the following to get the string
result = Convert.FromBase64String(resultArray );
Encoding.ASCII.GetString(result ) ;
Whats the corresponding VC++.
|
|
|
|
|