|
Are you familiar with the html tags. If affirmative, you can use the tags and write them to the file alongwith the result. The html file can be opened in HTML view.
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
Try one of the MFC controls, perhaps one of these[^].
I must get a clever new signature for 2011.
|
|
|
|
|
|
FILE *fp = fopen(filename, "w");
fprintf(fp, "<html>\n<body>\n");
fprintf(fp, all your data goes here);
fprintf(fp, "<\body>\n</html>");
fclose(fp);
|
|
|
|
|
GetNetworkParams failed in windows server 2003
Trioum
|
|
|
|
|
What is the return value?
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
|
Your problem description is really not very detailed. Do you expect people to guess what is going on in your program?
I must get a clever new signature for 2011.
|
|
|
|
|
Per MSDN:
If the function fails, use FormatMessage() to obtain the message string for the returned error.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi,
I want to implement a functionality in which when i click F2 on any Treeview item, it should display the Tooltip for that item (This is possible generally).But in Tooltip the text should be in tabular format and also should allow me to edit the value of the item text.
Please let me know if anyone has implemented this.
I am not sure whether its feasible or not...Please if anyone has any other idea which we can implement to achieve this functionality.
Thanks,
Nikhil
|
|
|
|
|
Hi,
I want to implement a functionality in which when i click F2 on any Treeview item, it should display the Tooltip for that item (This is possible generally).But in Tooltip the text should be in tabular format and also should allow me to edit the value of the item text.
Please let me know if anyone has implemented this.
I am not sure whether its feasible or not...Please if anyone has any other idea which we can implement to achieve this functionality.
Thanks,
Nikhil
|
|
|
|
|
Nikhil Sisodia wrote: the text should be in tabular format and also should allow me to edit the value of the item text. An easy way to do this would be to pop up a dialog box that contains a CListCtrl. The CListCtrl could have editable subitems. There are several articles on Codeproject on how to do this.
|
|
|
|
|
Hi guys...
Suppose I have selected the text in a rich edit control through( Ctrl + A) or mouse click and move, after I have only clicked on either selected or non-selected area, I want to deselect this text. It' look like deselected, but when I called GetSel() it gave me the starting and end selection point.
Thanks in advance.
|
|
|
|
|
You can use m_RichEdit.SetSel(0, 0); to deselect any selected text.
|
|
|
|
|
Hey. Basically I made a program that contains 17 * 7 number of boxes using two for loops, and they seem to work pretty well, until i resize it. Every single time i resize the window, the memory goes up by quite a bit, until the program fails with too much memory. I am pretty sure i deleted everything that i called for WM_PAINT, but I am not sure what other parts i might have overlooked. Is there any common mistakes that people would make for drawing a lot of GDI objects? Do I need to post my code to see which part went wrong?
here are the codes. sorry for asking the stupid question "do i need to post my code here" =_+;;
#include <windows.h>
COLORREF color[17][7];
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
HWND hwnd;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.lpszClassName = TEXT( "Window" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_INACTIVECAPTIONTEXT);
wc.lpszMenuName = NULL;
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
RegisterClass(&wc);
hwnd = CreateWindow( wc.lpszClassName,TEXT("BOXES"), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 800, 800, NULL, NULL,
hInstance,
NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while( GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
int i_row, j_column;
switch (msg)
{
case WM_CREATE:
{
for(i_row=0; i_row<17; i_row++)
{
for(j_column=0; j_column<7; j_column++)
{
color[i_row][j_column]=RGB(255,255,255);
}
}
break;
}
case WM_PAINT:
{
HDC hdc;
PAINTSTRUCT ps;
HPEN hPen,holdPen;
HBRUSH hBrush_1, holdBrush;
hdc = BeginPaint(hwnd, &ps);
hPen = CreatePen(PS_NULL, 1, RGB(0, 0, 0));
holdPen = SelectObject(hdc, hPen);
for(i_row=0; i_row<17; i_row++)
{
for(j_column=0; j_column<7; j_column++)
{
hBrush_1 = CreateSolidBrush(color[i_row][j_column]);
holdBrush = SelectObject(hdc, hBrush_1);
Rectangle(hdc, 90*j_column+100, 50+30*i_row, 90*j_column+180, 30*i_row+75);
}
}
DeleteDC(hdc);
DeleteObject(hPen);
DeleteObject(holdPen);
DeleteObject(hBrush_1);
DeleteObject(holdBrush);
EndPaint(hwnd, &ps);
break;
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
modified on Wednesday, March 9, 2011 5:01 AM
|
|
|
|
|
leorex wrote: Is there any common mistakes that people would make for drawing a lot of GDI objects?
maybe you are leaking handles/GDI objects? If the memory usage increases a lot, possibly you are creating bitmaps that never get freed up?
leorex wrote: Do I need to post my code to see which part went wrong?
that usually helps a lot, otherwise we can only guess. This is like as if you had a problem with your car so you'd call your mechanic and say "my car's engine is smoking, do i actually need to show you the car to get it fixed?".
In case you do decide to show code, only the relevant parts, please, and use <pre> </pre> tags to make it nicely formatted and readable.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
leorex wrote: Do I need to post my code to see which part went wrong? Yes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
What are you doing in your WM_SIZE handler?
|
|
|
|
|
I have updated the thread and posted my code there. Please point out the part where i went wrong tyvm
|
|
|
|
|
Please put your code between <pre></pre> tags (use the code block button), so it retains its formatting.
I must get a clever new signature for 2011.
|
|
|
|
|
your code is hard to read without proper formatting (pre tags are your friends ), but as i see it here:
leorex wrote: for(i_row=0; i_row<17; i_row++) { for(j_column=0; j_column<7; j_column++) { hBrush_1 = CreateSolidBrush(color[i_row][j_column]); holdBrush = SelectObject(hdc, hBrush_1); Rectangle(hdc, 90*j_column+100, 50+30*i_row, 90*j_column+180, 30*i_row+75); //rember is x, y, x, y
} }
you create a new brush in every iteration, but you will delete only the very last one, all the rest just leaks away happily. Also, in every iteration you overwrite the value of holdbrush , thus, unless you make exactly 1 iteration, you won't know the original brush and won't be able to select it back into the DC when you are done.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
PROBLEM SOLVED!!!
close to no memory leak with this in the for loop (still goes up by like a few bytes once in a while >.< but it doesnt really interfere with the program so i guess its ok =_=)
hBrush_1 = CreateSolidBrush(color[i_row][j_column]);
SelectObject(hdc, hBrush_1);
Rectangle(hdc, 90*j_column+100, 50+30*i_row, 90*j_column+180, 30*i_row+75);
DeleteObject(hBrush_1);
to be perfectly honest I do not get the explanation with holdbrush.
"you won't know the original brush and won't be able to select it back into the DC when you are done."
sorry if it is a neeeewb question, but why?
|
|
|
|
|
That solution looks better, but now you are deleting the brush while it is still selected into the DC, that is not healthy.
If i were you i'd just store the original brush somewhere in the beginnings (before the for loops...) and then use it along.
HBRUSH holdBrush = GetCurrentObject(hdc, OBJ_BRUSH);
...
hBrush_1 = CreateSolidBrush(color[i_row][j_column]);
SelectObject(hdc, hBrush_1);
Rectangle(hdc, 90*j_column+100, 50+30*i_row, 90*j_column+180, 30*i_row+75);
SelectObject(hdc, holdBrush);
DeleteObject(hBrush_1);
...
Well, about the other thing, i will try to explain. When you use SelectObject, it will return the handle to the previously selected tool of given type. So if you do this (example):
HBRUSH brush1 = CreateBrush...;
HBRUSH brush2 = CreateBrush...;
HBRUSH brush3 = CreateBrush...;
HBRUSH holdBrush = SelectObject(dc, brush1);
...draw...
holdBrush = SelectObject(dc, brush2);
...draw....
holdBrush = SelectObject(dc, brush3);
...draw....
SelectObject(dc, holdBrush);
DeleteObject(brush1);
DeleteObject(brush2);
DeleteObject(brush3);
...
In your code you did something similar in the loop, in every iteration you put the brush created in the previous iteration into holdBrush, the original, very first brush handle you should use in the end for the DC to perform the cleanup gets lost.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
U R LEGEND. I think I am getting it
|
|
|
|
|
Thanks. I think.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|