|
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
|
|
|
|
|
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.
|
|
|
|
|