|
Why are you opening the serial port twice ? You can read and write from the same CSerial instance. BTW, from where is this CSerial class coming from ?
|
|
|
|
|
Hello,
I want to make a very small application capable of screen capturing.
Plaese help me with some example.
Thanks & Regards.
Dhiraj
|
|
|
|
|
You could try something like this, don't know if this actually works or not, didn't try it, but it can be a starting point for you, good luck:
CDC ScreenDC;
ScreenDC.Attach(::GetDC(NULL));
CBitmap Capture;
CSize Dimensions(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
Capture.CreateCompatibleBitmap(&ScreenDC, Dimensions.cx, Dimensions.cy);
CDC MemDC;
MemDC.CreateCompatibleDC(&ScreenDC);
CBitmap *OldBitmap = MemDC.SelectObject(&Capture);
MemDC.BitBlt(0, 0, Dimensions.cx, Dimensions.cy, &ScreenDC, 0, 0, SRCCOPY);
MemDC.SelectObject(OldBitmap);
MemDC.DeleteDC();
::ReleaseDC(NULL, ScreenDC.Detach());
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
|
Actually you know the logic. Maybe you don't know the realtive API.
What are your doubts about? Are you able to open and read the file?
Are you able to open and write to the serial port?
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 am using a 3rd party library(.h and .lib file) in my project.
I create one win32 app It is running successfully. But whe I tried to same library with SDI app It is giving LNK 2019 linking error although I have add the library name in project settings.
This library have 4 function but linking errors is coming for only 2.
If I comment these 2 function, program succeed .
Could you tell me what might me the problem, I am using vc.net 2003
|
|
|
|
|
See, for instance, this [^].
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 every one
i want copy data from memory.is it possible ?
there are many tools for dumping process from memory but i want dump data from memory.
for example i want dump Stream of one pdf or doc file from memory . is it possible?
plz introduce me tool or articles about it.
thanks a lot
|
|
|
|
|
Probably I haven't got you. Do you really indend to dump the file content?
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 All
I want to open a application through shortcut key which is runing in background.Can any one tell me how can i do this?Plz help me
modified on Thursday, November 27, 2008 1:12 AM
|
|
|
|
|
Are you intending to implement a key board hook...something similar to (Window's Key+d) that minimizes all the open windows and leads you to the desktop window
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Check second reply to this[^] post.
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
|
I am glad it helped
Regards,
Sandip.
|
|
|
|
|
I want when I click next button ,next window should'nt appear until all the processing against next button is completed.I used Sleep(1000).It is doing but Interface color get black as I press next button.What should I do?
|
|
|
|
|
You can use polling technique to determine if a task is complete, or use some event notification to let you know about the task completion.
Alternatively, you can use a boolean variable and set it to true once the task is completed and keep on monitoring the variable until its set to TRUE.
Putting Sleep() in code is not a good idea. there are other techniques too.
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
can you do something like this.. Disable Next Button and Display a progress bar showing that some work going on. once your work is complete show your next window!. sleeping with halt your main thread!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
Possibly you have to use threads.
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]
|
|
|
|
|
Sleeping in GUI thread is not a good idea. Its recommended to avoid polling mechanism. But if situation demands it, then try using LockWindowUpdate() and UnlockWindowUpdate() . It might be helpful. Check the code snippet.
void CRabbitDlg::OnButton1()
{
LockWindowUpdate();
Sleep( 3000 );
UnlockWindowUpdate();
}
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
I want when I click next button ,next window should'nt appear until all the processing against next button is completed.I used Sleep(1000).It is doing but Interface color get black as I press next button.What should I do?
|
|
|
|
|
I'm working with byte arrays on Windows Mobile using native code. For some custom debugging purposes,(to make sure I'm setting everything up right) I want to read all my struct data, and spit their values back out in a text file using a combination of file writing functions and swprintf. Mostly, I seem to be using C functions.
Easy enough, but some of the data comes in the unfriendly form of byte arrays. Maybe it's a severe lack of Google-fu on my part, but most of the examples I find for converting raw bytes to Hex cite .NET and I want to avoid managed code for efficiency's sake. I also want to convert to Unicode since that's the default in WM anyway. I suppose I could convert ansi to Unicode after the fact, but I was wondering I overlooked something more direct.
Here's some code I found for ansi, but if I want to do wchar strings, what then?
Code:
.
.
.
DWORD j =0;
for(i=0; i < dwSizeOfStrBuf ; i++){
char ch = lpb[i];
char ch0 = (ch>>4) & 0x0F;
char ch1 = ch & 0x0F;
if((0<= ch0) && (ch0 <= 9))
pszCharArr[j] = '0' + ch0;
else
pszCharArr[j] = 'A' + (ch0 - 10);
j++;
if((0<= ch1) && (ch1 <= 9))
pszCharArr[j] = '0' + ch1;
else
pszCharArr[j] = 'A' + (ch1 - 10);
j++;
}
pszCharArr[j] = '\0';
Is there a more direct method of converting a byte array of length 'cb' to a Unicode hex string?
(I guess here is where I mention that up until now, I have actually NEVER done work with bit manipulation. No idea how, I've just never needed to, so to say I'm 'rusty' would be an understatement.)
"For I looked into the Future, far as human eye could see;
Saw the Vision of the world and all the wonder that would be." -- Alfred Tennyson
Beware Geeks bearing .gifs.
|
|
|
|
|
There is (the generic text mapping version of) sprintf for that, for instance
BYTE pb[]={0x46, 0x4F, 0x4F};
const int SIZE = sizeof(pb)/sizeof(pb[0]);
TCHAR *psz = new TCHAR[2*SIZE+1];
int i;
for (i=0; i<size;> {
_stprintf(psz+2*i, _T("%02x"), pb[i]);
}
psz[2*i]=_T('\0');
BTW the generic text version of your function is
DWORD j =0;
for (i = 0; i < dwSizeOfStrBuf ; i++)
{
BYTE b = lpb[i];
BYTE b0 = (b>>4) & 0x0F;
BYTE b1 = b & 0x0F;
if((0<= b0) && (b0 <= 9))
pszCharArr[j] = _T('0') + b0;
else
pszCharArr[j] = _T('A') + (b0 - 10);
j++;
if((0<= b1) && (b1 <= 9))
pszCharArr[j] = _T('0') + b1;
else
pszCharArr[j] = _T('A') + (b1 - 10);
j++;
}
pszCharArr[j] = _T('\0');
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]
|
|
|
|
|
Worked perfectly! Thanks for your expertise.
"For I looked into the Future, far as human eye could see;
Saw the Vision of the world and all the wonder that would be." -- Alfred Tennyson
Beware Geeks bearing .gifs.
|
|
|
|
|
I am facing problems trying to write text onto a bitmap in the hopes of getting pixelated text on it.
I have looked at the code shown here: <ahref>http://www.codeproject.com/KB/GDI/gdionbitmaps.aspx[^]
but I can't seem to get it to work right.
Here's my code, I am using the code shown on the above site and triggering it to run on a button click form a dialog:
void CCaptureAndDisplayDlg::OnTest()
{
HBITMAP hbitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));
BITMAP bitm;
GetObject( hbitmap, sizeof(BITMAP), &bitm );
long width=bitm.bmWidth;
long height=bitm.bmHeight;
BITMAPINFO bmInfo;
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth=width;
bmInfo.bmiHeader.biHeight=height;
bmInfo.bmiHeader.biPlanes=1;
bmInfo.bmiHeader.biBitCount=24;
HDC pDC = ::GetDC(0);
HDC TmpDC=CreateCompatibleDC(pDC);
BYTE *pbase;
HBITMAP TmpBmp=CreateDIBSection(pDC, &bmInfo,DIB_RGB_COLORS,(void**)&pbase,0,0);
HGDIOBJ TmpObj=SelectObject(TmpDC,TmpBmp);
HDC dcBmp=CreateCompatibleDC(TmpDC);
HGDIOBJ TmpObj2 = SelectObject(dcBmp,hbitmap);
BitBlt(TmpDC,0,0,width,height,dcBmp,0,0,SRCCOPY);
SelectObject(TmpDC,TmpObj2);
DeleteDC(dcBmp);
CFont m_Font;
LOGFONT* m_pLF;
m_pLF=(LOGFONT*)calloc(1,sizeof(LOGFONT));
strncpy(m_pLF->lfFaceName,"Times New Roman",31);
m_pLF->lfHeight=64;
m_pLF->lfWeight=400;
m_pLF->lfItalic=0;
m_pLF->lfUnderline=0;
m_Font.CreateFontIndirect(m_pLF);
CDC dc;
dc.Attach(TmpDC);
CFont* pOldFont=NULL;
if (m_Font.m_hObject)
pOldFont = dc.SelectObject(&m_Font);
else
dc.SelectObject(GetStockObject(DEFAULT_GUI_FONT));
dc.SetTextColor(RGB(0,0,0));
RECT pos = {40,40,0,0};
dc.SetBkMode(TRANSPARENT);
dc.DrawText(strTxt,TxtLen,&pos,DT_CALCRECT);
dc.DrawText(strTxt,TxtLen,&pos,0);
m_Placemat.SetBitmap(TmpBmp);
if (pOldFont) dc.SelectObject(pOldFont);
m_Font.DeleteObject();
dc.Detach();
free(m_pLF);
DeleteObject(hbitmap);
hbitmap=TmpBmp;
SelectObject(TmpDC,TmpObj);
DeleteDC(TmpDC);
}
m_Placemat is a Bitmap object embedded on the dialog window. It is how I am displaying the bitmap on screen.
I can get the bitmap out, but there does not seem to be any change from the original, no text, no visible difference. I seem to be getting the code wrong somehow. Can anyone enlighten me?
I have already posted on the comments section of the page witht he code, but I was hoping for some opinions from someone fast.
I'm running this using VC 6.0, no GDI+ library. If this truely cannot be done on pre-.Net, please tell me
My final objective is to get a text string into pixels or a bit array. If you have a better solution to achieve this, please let me know too.
Thanks.
|
|
|
|
|
It's no biggie, really.
I think you'll find the problem to lie in the fatc that you deselect your loaded bitmap from the DC before you draw the text on it.
Here's some plain win32 code that hacks togeter a result.
void DrawOnBitmap(HBITMAP hBmp)
{
HFONT oldFnt, font1;
HDC memDC;
HBITMAP oldBM;
char *myText = "CrackerJack";
memDC = CreateCompatibleDC(NULL);
oldBM = (HBITMAP)SelectObject(memDC, hBmp);
font1 = CreateFont(-13, 0, 0, 0, 400, FALSE, FALSE, FALSE, 1, 400, 0, 0, 0, "Tahoma Bold");
oldFnt = (HFONT)SelectObject(memDC, font1);
TextOut(memDC, 30, 30, myText, strlen(myText));
SelectObject(memDC, oldBM);
SelectObject(memDC, oldFnt);
DeleteObject(font1);
DeleteDC(memDC);
}
simon
modified on Thursday, November 27, 2008 12:52 AM
|
|
|
|
|