|
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
|
|
|
|
|
I have a source code written in borland c++.
How do I get it to run with visual c++
Thanks
Joe M
|
|
|
|
|
It depends of what you want to do... If these are simple classes that only use the standard C++ libraries, then you can just import them in your project.
|
|
|
|
|
when I run the code in visual c++, it's looking for
include file fstream.h.
How can I get that file/
Thanks
|
|
|
|
|
fstream.h is a header from the standard library...
is your program a console application, or windows ?
if it is a windowed apps, you'll have to learn from OWL to MFC or Win32...
one question, why do need to do such a thing ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi all,
I am making a small tool, which scans a specific file on the whole hard drive. I am making this application via a small Dialog based application. My dialog window will have three buttons "Scan", "Exit" and "About". I have a doubt
1) When user clicks the "Scan" button, the "Exit" button should change to "Stop" so the user can click this "Stop" button to stop the scan, while my tool is scanning the hard drive. Basically this "Exit" should act like TOGGLE style.
How to do this ?
K.K.Senthil Velan
Information Assurance Engineer
|
|
|
|
|
Hello
You need to use threads to handle messages while your project scan hard disk
Iman Ghasrfakhri
|
|
|
|
|
Do it like this:
In header:
private:
BOOL m_bWorking;
public:
void DoScan();
static DWORD __stdcall ThreadScanner(LPVOID lpVoid);
-----
In OnInitDialog()...
m_bWorking = FALSE;
-----
In OnStartScan()...
DWORD id;
CreateThread(NULL,0,ThreadScanner,this,0,&id);
CButton* pButton = (CButton*)GetDlgItem(IDC_BTN_EXIT);//IDC_BTN_EXIT is the id for your Exit Button.
pButton->SetWindowText("Stop Scan");
m_bWorking = TRUE;
-----
DWORD __stdcall CScanDlg::ThreadScanner(LPVOID lpVoid)//where CScanDlg is you dialog class.
{
CScanDlg* pParent = (CScanDlg*)lpVoid;
pParent->DoScan();
return 0;
}
-----
In OnScan()...
while (m_bWorking)
{
Do the scanning here...
}
-----
in OnExit()...
if (m_bWorking == FALSE)
CDialog::OnCancel();
else
{
m_bWorking = FALSE;
CButton* pButton = (CButton*)GetDlgItem(IDC_BTN_EXIT);
pButton->SetWindowText("Exit");
}
Any problems understanding the code?
Please say if it does not work.
Happy Coding.
this is this.
|
|
|
|
|
khan++ wrote:
CreateThread(NULL,0,ThreadScanner,this,0,&id);
Since this is an MFC application, AfxBeginThread() must be used.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello,
I am writing an application in which user can type sentences.I need to change colors some keywords in that sentence into blue. How can i accomplish this task in VC++.
Thanks in advance ,
John.
|
|
|
|
|
You don't give us a lot of useful informations ! What kind of application are you doing ? Console, Win32 ? With or without MFC ? And where is this text written ? In a control or what ?
|
|
|
|
|
Thanks for the fastest reply.
I am developing a SDI application using MFC and the text will be written in the SDI's views . I am currently not using any kind of special controls.
Once again,Thanks.
John.
|
|
|
|
|
emmatty wrote:
I am developing a SDI application using MFC and the text will be written in the SDI's views
Easiest way to Get above would be use CRichEditView instead of CView!.
And Cedric -I am back in race
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Is CDC::SetTextColor of any help ?
|
|
|
|
|
Long time no see Bro
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Yep . You were in hollidays ?
|
|
|
|
|
cedric moonen wrote:
You were in hollidays ?
Yeap, celebrating holiday in hospital since last thursday due to intestine infection . Now All ok!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Ouch.... Not so funny holidays
|
|
|
|
|
Hi
Please i want some information related to OpenGL and win32 Dialog
Actually i want to show open Gl window in the right corner of my dialog.
i want to create so that animation remains runninig in its own openGL window and i can give other controls on the left side
If anybody knows please help me.
Give me some link of tutorial or some link of sample code or if you have any such application you can send me or if you have any idea please let me know
i Will be very thankful to you;
Always be Happy When things done
|
|
|
|
|