|
|
thanks for your reply.
but, AnimateWindow does not help i think.
i want to move the window from one Rect to another Rect smoothly.
|
|
|
|
|
and, why SetWindowPos make the window 'resize' and 'reposition' seperetely?
does anybody know?
thank you.
|
|
|
|
|
I guess it is because reposition and size lead both to a repaint of the window. You could use validaterect() or validatewindowrgn() (these are GDI-functions, look for GDI+ equivalents) after reposition so windows believes there's no need to repaint. Then repainting only occurs after size showing the reposition also.
Hope this will work...
|
|
|
|
|
|
it seems did not work with the solution below .
|
|
|
|
|
Hi,
I have used the code below to draw rotated text using DrawText.
//Draw rotated text
double Escapement = -401;
CString str = "Hello World";
CFont newFont;
newFont.CreateFont(24, 0, Escapement, Escapement, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
CFont* pFont = pDC->SelectObject(&newFont);
// draw the text
CSize TextSize = pDC->GetTextExtent(str);
CRect rect(0,0,TextSize.cx, TextSize.cy);
pDC->DrawText(str, str.GetLength(), rect, DT_CENTER);
Text is diplayed fine for non-rotated text. But for rotated text(ie, with Escapemnt != 0), the text appears to be clipped or sometimes not displayed at all. This is because the rect value is too restrictive for rotated text.
Please can someone help me to deduce the rect value correctly for rotated texts?
Regards
Mary
|
|
|
|
|
you might try using DrawText with the DT_CALCRECT flag
|
|
|
|
|
Yes I tried using DT_CALCRECT. But that isn't giving me a rotated rectangle.
|
|
|
|
|
FYI:
1. DT_CALCRECT returns the size of the bounding rectangle.
2. A rotated rectangle is still a rectangle.
|
|
|
|
|
Me think the rectangle is aligned to the coordinate system or the "screen", not to the coordinate system of the rotated text.
Watched code never compiles.
|
|
|
|
|
As suggested by Maximilien the computed rectangle is always aligned to screen coordinate space (i.e. rotation is not performed).
The following code (warning is a quick and dirty hack...)
#include <float.h>
#include <math.h>
CSize TextSize = dc.GetTextExtent(str);
double x[4],y[4];
double alpha = ((double) Escapement) * atan(1.) * 4 / 1800;
x[0] = .0;
y[0] = .0;
x[1] = TextSize.cx * cos(alpha);
y[1] = -TextSize.cx * sin(alpha);
x[2] = TextSize.cx * cos(alpha) +TextSize.cy * sin(alpha);
y[2] = - TextSize.cx * sin(alpha) + TextSize.cy * cos(alpha);
x[3] = TextSize.cy * sin(alpha);
y[3] = TextSize.cy *cos(alpha);
double xoff=0.,yoff = 0.;
for (int i=0; i<4; i++)
{
if ( xoff > x[i] ) xoff = x[i];
if ( yoff > y[i] ) yoff = y[i];
}
for (int i=0; i<4; i++)
{
x[i]-=xoff;
y[i]-=yoff;
}
dc.MoveTo(x[0],y[0]);
dc.LineTo(x[1],y[1]);
dc.LineTo(x[2],y[2]);
dc.LineTo(x[3],y[3]);
dc.LineTo(x[0],y[0]);
double xmin = DBL_MAX;
double ymin = DBL_MAX;
double xmax = 0.;
double ymax = 0.;
for (int i=0; i<4; i++)
{
if (xmin > x[i]) xmin = x[i];
if (ymin > y[i]) ymin = y[i];
if (xmax < x[i]) xmax = x[i];
if (ymax < y[i]) ymax = y[i];
}
CBrush *pOldBrush = (CBrush*)dc.SelectStockObject(NULL_BRUSH);
dc.Rectangle(xmin, ymin, xmax, ymax);
dc.SelectObject(pOldBrush);
CRect rect(xmin-xoff,ymin,xmax-xoff,ymax);
dc.DrawText(str, str.GetLength(), rect, DT_NOCLIP);
Shows you:
- The 'rotated text bounding rectangle'
- The 'screen aligned rectangle' bounding the rotated one
- The rotated text
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]
|
|
|
|
|
Hi , I hv a char buffer(say 1024 bytes) with lots of data, I want to read data from that buffer, but at one time I can read only some of character(say 255 bytes). I need to read all the data from the buffer and place excatly after the last cahrcter I read (say after the first 255 bytes I need to put second part of the buffer and so on.. until the full buffer I read).
Please help me in this regards..
If possible please provide me some sample code.
Thanks..
|
|
|
|
|
Looks like a fairly simple task to me. What's exactly your problem about?
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]
|
|
|
|
|
for starting position to end of buffer_to_read_from
for temporary variable i to length of secondary buffer
copy a single <insert data type> from source(offset starting position) to destination buffer;
increment variable i
increase starting position by the length of the secondary buffer size
That is probably what you are looking for. Simple thing really, should be able to figure it out quite simply with just a little bit of extra thought.
|
|
|
|
|
thanks for reply,
My acutal dat is like
char *str = "1,2,3\r\n1,3,4\r\n3,4,5\r\n1,3,5\r\n2,3,1\r\nCMD OK\r\n"
but first time I m getting only
char* temp = "1,2,3\r\n1,3,4\r\n3,4,"
I need to read upto last \r\n and keep the remaining (3,4) in some temporery variable, and the next time wen I'll get the another set of data then I need to append the tepory data with the new one, I hv to do the same task until I m not getting the "CMD OK\r\n".
I need to do like that becz every comma seperated value has to be store in seperate array.
Can u please send me some sample code for that..
Thanks..
|
|
|
|
|
this is how you may do it.
char buffer[100][10] = {0};
int i = 0;
char seps[] = "\r\n";
bool ok = false;
while(incoming data)
{
char data[] = "1,2,3\r\n1,3,4\r\n3,4,";
char temp[100];
strcpy(temp, data);
char *token = strtok( temp, seps );
while( token != NULL )
{
if(! strcmp(token, "CMD OK"))
{
ok = true;
break;
}
strcat(buffer[i++], token);
token = strtok( NULL, seps );
}
if(ok);
break;
if( strcmp(&data[strlen(data)-2], "\r\n"))
--i;
}
hope strtok is known to you. never ask here for this kinda simple codes ever. you may not get it more
|
|
|
|
|
Dude, didn't some of us give the reply as well as the code to the exact same question you asked elsewhere? I too have given here. Why don't you try to work with them and not litter the forums with same questions.
...byte till it megahertz...
|
|
|
|
|
hi to everyone here is my code below and i am newbie to programming
#include"stdafx.h"
#include"windows.h"
#include"winnt.h"
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int ncmdShow)
{
HANDLE hImage;
DWORD dwExitCode = 0;
IMAGE_DOS_HEADER imgdosh={0};
hImage = CreateFileA("E:\\kill.exe",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if (INVALID_HANDLE_VALUE == hImage)
{
MessageBoxA(NULL,"invalid file","err",MB_OK);
}
HANDLE hfilemaping = CreateFileMapping(hImage,NULL,PAGE_READONLY,0,0,0);
{
if(!hfilemaping)
{
MessageBoxA(NULL,"Mapping Fails","err",MB_OK);
}
HANDLE ndmapview = MapViewOfFile(hfilemaping,FILE_MAP_READ,0,0,0);
if(!ndmapview)
{
MessageBoxA(NULL,"Mapping Fails","err",MB_OK);
}
if (IMAGE_DOS_SIGNATURE != imgdosh.e_magic)
{
MessageBoxA(NULL,"not a dos file","Suuc",MB_OK);
}
if (IMAGE_DOS_SIGNATURE == imgdosh.e_magic)
{
MessageBoxA(NULL,"dos file","Suuc",MB_OK);
}
return 0;
}
}
Question - Test.exe is a PE file but my program returns me a msgbox that "it is not a dos file".?
what is the mistake i have done please can anyone help me to figure out.?
Regards
0x8085
|
|
|
|
|
I have no idea on PE file reading. Wow, you are newbie and started coding with PE.
where is your imgdosh correctly initialized? Did you miss any code for that? You initialized to 0 in the beginning, there is no code to set the values to it and you are checking for
if(IMAGE_DOS_SIGNATURE != imgdosh.e_magic).
Is this correct or am I missing something?
|
|
|
|
|
Hi mk14882,
thanks for replying.
yes that was the mistake i think .. but i dint know how to fix it..still i am going googling for it.
Regards
0x8085
|
|
|
|
|
0x8085 wrote: Test.exe
what is that file ? is it the same as "kill.exe" that is written in the example ?
What makes you think that creating an file makes it a PE (Portable Executable) file ?
anyway, you do nothing with imgdosh ...
Watched code never compiles.
|
|
|
|
|
hi,
Kill.exe is a small PE file with a function to display message box hello world.
i want to create a file to an application to check whether the file is a pe file or not.
for that i started with a first step of verifying the dos signature.
you change the path "e:\\kill.exe" to any pe file it will compile.
regards
0x8085
|
|
|
|
|
Some time back I read Vijay mukhi's website on PE files. I thought it was not my world and left it.
Here is the link if it can help you: http://www.vijaymukhi.com/security/windows/pefile.htm[^]
The return type of MapViewOfFile() is LPVOID. Check it out if it can cause any issue.
|
|
|
|
|
hi mk14882,
Thanks a lot.. I think this would help me..
thank you once again..
I will check it and let you know.
Regards
0x8085
|
|
|
|
|