|
How can i create word editor in c++?
Please Help me.
|
|
|
|
|
Have a look at the WordPad sample.
|
|
|
|
|
Hi All,
I am using a function foo() in "a.cpp" in Proj.lib
The function extern foo() is decalred in "b.h" in Proj.lib.
The extern foo() is defined in c.cpp in another Sample.dll
I am getting LNK2001:unresolved external symbol foo in a.obj..
How can i solve this ....
Thanks,
Hari
|
|
|
|
|
Put the name of the lib file corresponding to the library in which foo is defined in Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies .
|
|
|
|
|
Thats done ... i have added the lib in the Proj settings...
|
|
|
|
|
I have made that Proj setting changes and its still not working...
|
|
|
|
|
is the function being exported ? with __declspec(dllexport) ?
|
|
|
|
|
Yes i have used DLLExport and the issue is solved .. Thanks
|
|
|
|
|
hi everyone. i want to create a window which can zoom out from the center,but the window swung when i use MoveWindow/SetWindowPos to reposition and resize the window.
it was just like the situation below.
1:____[--]____ (original place)
2:___[--]_____ (rePosition) the right side of the window has gone astern
3:___[----]___ (reSize)
4:__[----]____ (rePosition)
5:__[------]__ (reSize)
6:_[------]___ (rePosition)
7:_[--------]_ (final place)
does anyone has the solution about that?
code as below.
void CWindowAnimateDlg::DrawBackground()
{
CDC* dc=this->GetWindowDC();
HDC hdcMemory=CreateCompatibleDC(dc->GetSafeHdc());
CRect rct;
GetWindowRect(&rct);
BITMAPINFO bmih;
ZeroMemory( &bmih, sizeof( BITMAPINFO ) );
bmih.bmiHeader.biSize = sizeof (BITMAPINFOHEADER) ;
bmih.bmiHeader.biWidth = rct.Width() ;
bmih.bmiHeader.biHeight = rct.Height() ;
bmih.bmiHeader.biPlanes = 1 ;
bmih.bmiHeader.biBitCount = 32;
bmih.bmiHeader.biCompression = BI_RGB ;
bmih.bmiHeader.biSizeImage = 0 ;
bmih.bmiHeader.biXPelsPerMeter = 0 ;
bmih.bmiHeader.biYPelsPerMeter = 0 ;
bmih.bmiHeader.biClrUsed = 0 ;
bmih.bmiHeader.biClrImportant = 0 ;
HBITMAP hBitMap;
hBitMap = CreateDIBSection (NULL, &bmih, 0, NULL, NULL, 0) ;
HBITMAP oldBitmap=(HBITMAP)SelectObject(hdcMemory,hBitMap);
Graphics gpc(hdcMemory);
gpc.SetCompositingMode(CompositingModeSourceCopy);
DWORD dwExStyle=GetWindowLong(m_hWnd,GWL_EXSTYLE);
SetWindowLongA(m_hWnd,GWL_EXSTYLE,dwExStyle|WS_EX_LAYERED);
HDC hdcScreen=::GetDC(m_hWnd);
CDC cdc;
cdc.Attach(hdcScreen);
CDC cdc2;
cdc2.Attach(hdcMemory);
if(m_bkImage)
{
gpc.DrawImage(
m_bkImage,
Rect(0,0,rct.Width(),rct.Height()),
0,0,m_bkImage->GetWidth(),m_bkImage->GetHeight(),
UnitPixel
);
}
POINT ptWinPos={rct.left,rct.top};
POINT ptSrc={0,0};
SIZE sizeWindow={rct.Width(),rct.Height()};
BLENDFUNCTION blend;
blend.BlendOp=0;
blend.BlendFlags=0;
blend.AlphaFormat=AC_SRC_ALPHA;
blend.SourceConstantAlpha=255;
UpdateLayeredWindow( &cdc,&ptWinPos,
&sizeWindow,&cdc2,&ptSrc,0,&blend,ULW_ALPHA);
::SelectObject(hdcMemory,oldBitmap);
ReleaseDC(dc);
gpc.ReleaseHDC(hdcMemory);
::ReleaseDC(m_hWnd,hdcScreen);
DeleteObject(hBitMap);
DeleteDC(hdcMemory);
hdcMemory=NULL;
}
void CWindowAnimateDlg::OnTimer(UINT_PTR nIDEvent)
{
switch(nIDEvent)
{
case 1:
{
CRect rect;
GetWindowRect(&rect);
CRect nRect;
int l,t,r,b;
l=m_targetRect.left-rect.left;
t=m_targetRect.top-rect.top;
r=m_targetRect.right-rect.right;
b=m_targetRect.bottom-rect.bottom;
nRect.SetRect(
rect.left+(l>0?l/5+1:l/5-1),
rect.top+(t>0?t/5+1:t/5-1),
rect.right+(r>0?r/5+1:r/5-1),
rect.bottom+(b>0?b/5+1:b/5-1)
);
if(
abs(l)<2&&
abs(t)<2&&
abs(r)<2&&
abs(b)<2
)
{
KillTimer(1);
MoveWindow(&m_targetRect);
break;
}
MoveWindow(&nRect);
}
}
CDialog::OnTimer(nIDEvent);
}
void CWindowAnimateDlg::OnWindowPosChanged(WINDOWPOS* lpwndpos)
{
CDialog::OnWindowPosChanged(lpwndpos);
if(!(lpwndpos->flags&SWP_NOSIZE))
DrawBackground();
}
void CWindowAnimateDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
if(m_state==1)
{
m_state=2;
m_targetRect.SetRect(550,300,650,400);
SetTimer(1,30,NULL);
}
else if(m_state==2)
{
m_state=1;
m_targetRect.SetRect(150,150,950,550);
SetTimer(1,30,NULL);
}
CDialog::OnLButtonDown(nFlags, point);
}
|
|
|
|
|
|
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..
|
|
|
|
|