|
I think the easiest way for doing that is use a member variable of the class. Use a boolean for example. And, at the begining of your OnChangeEdit function, check if this boolean is true or false. If it is false, return, otherwise continue.
I don't think this will complicate your program a lot
|
|
|
|
|
You obviously type faster than I do... (See my post below...)
|
|
|
|
|
Yes, it seems ... But I think it is a rather common solution also
|
|
|
|
|
I have not ever been aware of such a command, not since Windows 3.1 anyways.
I usually set a boolean that I test in the OnChangeEdit. If the boolean is true, then just return from the OnChangeEdit. Set it before changing your text, clear it after done changing the text.
|
|
|
|
|
I want to translate ,scale and rotate a polygon
using win32 GDI or API's
you can also use the XForm matix to achive this
i'am unable to do it properly ,could some one help on this
thanks in advance
pradish
thanks in advance
pradish
|
|
|
|
|
I never used XForm so I have no idea what function you'd call to apply the transform. I suggest you look up 2D transformations.
For example here is an examlpe of what you're talking about.
To summarize:
Translations are easy, all you do is take each point in your polygon and add an offset to it to shift each point.
Scaling you perform by multiplying each point by some number. However if you just do scaling on each point of the polygon you're scaling about the screen origin so your polygon will move. To do scaling on the polygon only you'd need to translated it to center the polygon at (0,0) coordinates and then apply scaling, then apply the inverse transform to move it back to where it was.
Rotation is similar. You're multiplying each point by some sines and cosines, but you have to consider about which point you're rotating your polygon.
|
|
|
|
|
Thank you Budric,it was very informative
and Thanks for the link that is just funtastic
|
|
|
|
|
Has anyone tried Jeffrey Richter's IAT patching technique on IE to intercept wininet calls? I cant seem to get it working, so would like to know other's experiences to decide if digging deeper is worth trying.
Basically, none of the modules in IE seem to have WININET functions like InternetConnectW or HttpSendRequestW in their import tables, but windbg does show IE calls them.
Thanks in advance
|
|
|
|
|
Hi,
//Formatting of the code supplied
I am writing an application which supports loading, processing, and displaying of various image file formats.
I have a class, CDib, derived from CBitmap that displays the bitmap data on the device context supplied using BitBlt(...). I think this is a fairly general way dc voodoo.
//!Code Snippet (1)
//!CDib is derived from CBitmap
//!@param dc: reference to CDC where the image is to be drawn
//!@param pbm: CBitmap pointer that contains the image data, in most cases a pointer to itself
<code>
BOOL CDib::Draw(CDC& dc, CBitmap* pbm, const CRect* rcDst, const CRect* rcSrc)
{
CRect rc;
if (!rcSrc) {
// if no source rect, use whole bitmap
rc = CRect(CPoint(0,0), GetBitmapSize(pbm));
rcSrc=&rc;
}
if (!rcDst)
// if no destination rect, use source
rcDst=rcSrc;
bool bRet;
//Create a memory DC and load the bitmap onto it
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap* pOld = (CBitmap*)(memDC.SelectObject(pbm));
if(rcSrc->Size() == rcDst->Size()){
bRet = dc.BitBlt(rcDst->left, rcDst->top,
rcDst->Width(), rcDst->Height(),
&memDC, rcSrc->left, rcSrc->top, SRCCOPY);
} else{
dc.SetStretchBltMode(COLORONCOLOR);
bRet = dc.StretchBlt(rcDst->left, rcDst->top,
rcDst->Width(), rcDst->Height(),
&memDC, rcSrc->left, rcSrc->top, rcSrc->Width(), rcSrc->Height(),
SRCCOPY);
}
//!Delete the memory DC
memDC.DeleteDC();
return bRet;
}</code>
This function works fine if I load a BMP file using CBitmap::LoadImage(...).
Now,since the program can load other image file formats, I tried using CBitmap::CreateBitmap(...) but that didn't work. So, what I have done now is to use CreateCompatibleBitmap(...) and CreateCompatibleDC(...) to create a CDC and CBitmap object, and then linked them together using SelectObject(..), and then use SetPixel(...), now the problem is that SetPixel(...) is very very slow. I want to ask the readers if there is an alternate way to SetPixel where I can load a chunk of image data to the CBitmap object, and then pass it to CDib::Draw(..) function.
<code>//!Code snippet 2
//!@param pData: image data that needs to be displayed
void CImageDraw::CreateBitmap(BYTE* pData)
{
//!Create a DC
CDC dc;
dc.CreateCompatibleDC(NULL);
//!If m_dib exists delete it
if((HBITMAP)m_dib)
m_dib.DeleteObject();
m_dib.CreateCompatibleBitmap(AfxGetMainWnd()->GetDC(), m_nImgWidth, m_nImgHeight);
CBitmap *pOldBitmap = (CBitmap *)dc.SelectObject(&m_dib);
for(int y = 0; y < m_nImgHeight; y++){
for(int x = 0; x < m_nImgWidth; x++){
//!This is very very slow.....I need an alternative
dc.SetPixel(x,m_nImgHeight-1-y, RGB(pData[3*x+2+y*m_nImgWidth*3], pData[3*x+1+y*m_nImgWidth*3], pData[3*x+y*m_nImgWidth*3]));
}
}
dc.SelectObject(pOldBitmap);
dc.DeleteDC();
}
</code>
Thanking in anticipation
Swati<code></code>
|
|
|
|
|
The reason I use such ugly code, is because that's the only code I know. I am a begginer in programming. At the moment I am reading some materials on STL and MFC, but find it quite difficult to understand, as I have a lot of gaps in my programming knowledge. To that I have no one to ask for help apart from the forum. So THANK YOU all for helping me out!
Maybe you could help me out with this error I get:
cannot convert parameter 1 from 'unsigned short' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast.
The solutions you helped me out with, was not exaclty what I was looking for. Basicaly pszData is only 1 character at a time. So I want to store that 1 character in an array, then add the next character that comes from pszData and add it to the array. When I have 10 characters, That's when I want to display on screen. pszData recieves a character at different times, could be a split second or a whole day.
Thanks in Advance!
void CChildView::SortData(LPCTSTR pszData)<br />
{<br />
TCHAR buffer[10];<br />
<br />
????? I have no idea what to put here ???? <br />
Can anyone please help me.<br />
<br />
buffer[10] = _T('\0');
DisplayData(buffer);<br />
There is no fixed set of rules according to which clear, understandable, and provable programs can be
constructed. There are guidelines, of course, and good ones at that; but the individual programmer's style
(or lack of it), his clarity of thought (or lack of it), his creativity (or lack of it), will all contribute
significantly to the outcome.
-- Peter J. Denning
|
|
|
|
|
hello there,
First of all, don^t forget that the first position in an array is position 0. so if you have an array of 10 elements the tenth element is at array[9]!
In the code you posted you should make your buffer an array of 11 if you want to do:
TCHAR buffer[11],<br />
...<br />
buffer[10] = _T('\0');<br />
Then to copy the first 10 chars of the pszData string you could use:
_tcsncpy( buffer, pszData,10); <br />
Hope this gets you along...
<edit>
Sorry I did not read your post completely correct at first
From what I understand this function will be called multiple times an after the tenth time you want to display the 10 chars passed. you could do like this:
void Childview::SortData(LPCTSTR pszData)<br />
{<br />
static int nPass=0;<br />
static LPTSTR buffer[11];<br />
buffer[nPass++] = pszData[0];<br />
if( nPass == 10 )<br />
{<br />
buffer[10] = NULL;<br />
DisplayData(buffer);<br />
nPass = 0;<br />
}<br />
<br />
}
Allthough I think it would be better if you just passed a single TCHAR as parameter and not the string, but that is up to you....
<\EDIT>
Davy
|
|
|
|
|
Thanks, I will try it... the reason I want to store it in an array, is because I want to sort out the data, There is actualy 80characters that I need to store in the array, and only send to the display about 10.
The program recievs data from a COM port(rs-232), I got the program from this website, and just want to modify it. I write simple code, as it's what I am familuar with.
Thanks!
are you australian?
|
|
|
|
|
tomek18 wrote:
are you australian?
Nope. I`m no bloke from down-under.
100% European. Born and raised in tiny Belgium, and about 5years ago moved to and still living in sunny Greece
Greetings,
Davy
|
|
|
|
|
GDavy wrote:
Born and raised in tiny Belgium
Cooool, a compatriot .
|
|
|
|
|
Potverdikke, It's great to see a Belgian!
|
|
|
|
|
Gotferdom yes
|
|
|
|
|
GDavy wrote:
buffer[nPass++] = pszData[0];
gives me error, I always get a simular error with other methods:
error C2440: '=' : cannot convert from 'const unsigned short' to 'unsigned short *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or funtion-style cast
GDavy wrote:
DisplayData(buffer);
error C2664 : 'DisplayData': cannon convert parameter 1 from 'unsigned short *[11]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
What do you suggest I should try next?
|
|
|
|
|
I`m so sorry... I posted you a bug
Dont do LPTSTR buffer[11], but TCHAR buffer[11]
sorry
|
|
|
|
|
Thank's Dave! It works
Got another reoccuring problem you might help me with.
when I send a characters throught the com port, the other computer recieves them, and it is fine if each character is send no more then twice. But if it is so, then the 2nd computer recieves something like this, if 0 (zero) is send for example, it displays '00°0°0°0°0°0°0°0°0' it happened to me before, even so if I change the code to it's original form. To repair the program, I need to download the source code again, and re-complie.
What do you think the problem might be? Any suggestions?
Cheers.
btw. I am from downunder, and living in Germany.
|
|
|
|
|
Hi,
I am writing an application which supports loading, processing, and displaying of various image file formats.
I have a class, CDib, derived from CBitmap that displays the bitmap data on the device context supplied using BitBlt(...). I think this is a fairly general way dc voodoo.
//!Code Snippet (1)
//!CDib is derived from CBitmap
//!@param dc: reference to CDC where the image is to be drawn
//!@param pbm: CBitmap pointer that contains the image data, in most cases a pointer to itself
BOOL CDib::Draw(CDC& dc, CBitmap* pbm, const CRect* rcDst, const CRect* rcSrc)
{
CRect rc;
if (!rcSrc) {
// if no source rect, use whole bitmap
rc = CRect(CPoint(0,0), GetBitmapSize(pbm));
rcSrc=&rc;
}
if (!rcDst)
// if no destination rect, use source
rcDst=rcSrc;
bool bRet;
//Create a memory DC and load the bitmap onto it
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap* pOld = (CBitmap*)(memDC.SelectObject(pbm));
if(rcSrc->Size() == rcDst->Size()){
bRet = dc.BitBlt(rcDst->left, rcDst->top,
rcDst->Width(), rcDst->Height(),
&memDC, rcSrc->left, rcSrc->top, SRCCOPY);
} else{
dc.SetStretchBltMode(COLORONCOLOR);
bRet = dc.StretchBlt(rcDst->left, rcDst->top,
rcDst->Width(), rcDst->Height(),
&memDC, rcSrc->left, rcSrc->top, rcSrc->Width(), rcSrc->Height(),
SRCCOPY);
}
//!Delete the memory DC
memDC.DeleteDC();
return bRet;
}
This function works fine if I load a BMP file using CBitmap::LoadImage(...).
Now,since the program can load other image file formats, I tried using CBitmap::CreateBitmap(...) but that didn't work. So, what I have done now is to use CreateCompatibleBitmap(...) and CreateCompatibleDC(...) to create a CDC and CBitmap object, and then linked them together using SelectObject(..), and then use SetPixel(...), now the problem is that SetPixel(...) is very very slow. I want to ask the readers if there is an alternate way to SetPixel where I can load a chunk of image data to the CBitmap object, and then pass it to CDib::Draw(..) function.
//!Code snippet 2
//!@param pData: image data that needs to be displayed
void CImageDraw::CreateBitmap(BYTE* pData)
{
//!Create a DC
CDC dc;
dc.CreateCompatibleDC(NULL);
//!If m_dib exists delete it
if((HBITMAP)m_dib)
m_dib.DeleteObject();
m_dib.CreateCompatibleBitmap(AfxGetMainWnd()->GetDC(), m_nImgWidth, m_nImgHeight);
CBitmap *pOldBitmap = (CBitmap *)dc.SelectObject(&m_dib);
for(int y = 0; y < m_nImgHeight; y++){
for(int x = 0; x < m_nImgWidth; x++){
//!This is very very slow.....I need an alternative
dc.SetPixel(x,m_nImgHeight-1-y, RGB(pData[3*x+2+y*m_nImgWidth*3], pData[3*x+1+y*m_nImgWidth*3], pData[3*x+y*m_nImgWidth*3]));
}
}
dc.SelectObject(pOldBitmap);
dc.DeleteDC();
}
Thanking in anticipation
Swati
|
|
|
|
|
I have a data in the view, it is like column based.I would like to save that into .html format.I need the source for that.Plz.......
Ashok.R
|
|
|
|
|
I assume you have the data in your variables.
Open a file on the HDD with extension ".html";
CString str, strData;
str = "<html>[DATA]</html>";
now, you insert data into strData like this:
for (i = 0; i < items_to_be_inserted; i++
{
strData += your_values[i];
strData += "<br>";
}
str.Replace("[DATA]",strData);
Now write str down to the file.
You can do some formatting on your code, like put it in tables etc. For that, contact an HTML programmer.
this is this.
|
|
|
|
|
Hi all!
I have created a .resx file for Greek language using visual studio. That file supposed to be used by .NET projects that support this file. However afterwards they asked me to use the same file just as it is in C++ projects without .NET!
I found a C++ XML parser that works fine. The tags can be read with no problems, but when I have to read the string with the Greek characters I never get the desirable result. When i open the same file in notepad the Greek characters are printed fine. When i open it in WordPad i get the same result as i get in my console application. Does anyone have any idea why is that happening and how could i solve the problem?
|
|
|
|
|
before long, the program can run without error,but today it don't run.
m_pConnection.CreateInstance("ADODB.Connection") return 0, and there is the exception----First-chance exception in GIS.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
i write it in mfc.
how can figure it out ?
|
|
|
|
|
Is m_pConnection a pointer? Is it a valid object?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|