|
I'm not really motivated to go through your code line by line.
But I don't get why you're working with both CString and also char * buffers and libc string functions. I'd say stick with one or the other.
using _mbs???() functions is wrong. They're for wide character sets, and you're dealing with byte data.
1. You want a \r\n at the end of your string? Put it in your format string:-
CString szMsg;
szMsg.Format("%02X%02X%02X%02X%02X%02X%02X<font color="red">\r\n</font>", cBuffer[0], cBuffer[1], cBuffer[2],cBuffer[3], cBuffer[4], cBuffer[5], cBuffer[6]);
or, you can use CString's "+" operater to join two strings:-
CString szMsg;
szMsg.Format("%02X%02X%02X%02X%02X%02X%02X", cBuffer[0], cBuffer[1], cBuffer[2],cBuffer[3], cBuffer[4], cBuffer[5], cBuffer[6]);
szMsg = szMsg + "\r\n";
2. Not using _mbscpy
I don't know where you get your "len" variable from. But use strcpy() instead.
unsigned char* myBuffer = new unsigned char[len];
strcpy(myBuffer, cBuffer);
Those things should help.
Jon
using System.Beer;
|
|
|
|
|
Hello!everyone!how to use a web serivce which is produced by java in VC6.0?If you kinow ,please tell me more about it .Thanks a lot !
|
|
|
|
|
Hi all,
I want to create a ActiveX using mfc.
and I want to add a dialog and some objects,
to my dialog and when I Insert this activex
in my project the dialog and those objects should
add to my app.
Best Regards.
Thanks.
|
|
|
|
|
Hello everyone:
I program code in Japanese OS. And I found that CEdit::LineLength() can not return total bytes of one line. The function returns total character number of one line.
Example:
1. "1234日本90" --->>> LineLength -> 8
2. "1234567890" --->>> LineLength -> 10
About Example 1, it should return 10 but the result is 8.
Is it right? or I need to set up something?
Thanks.
-Freehawk
|
|
|
|
|
I do not know an exact answer to your problem, but I'm fairly certain it is Unicode related. With Unicode, each character consumes two bytes, which is why example 1 is two bytes short of what you expect. You might try defining both UNICODE and _UNICODE in your project's stdafx.h file.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
hi everybody,
Can any one of u help me to brushing on a ownder draw button
I have few owner draw buttons on a dialogbox which is created in an SDI application and now i want to change the color of the buttons
can any one tell me what code do i need to write for that my code is as follow
void MybutCls::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, DFC_BUTTON,DFCS_BUTTONPUSH|BS_DEFPUSHBUTTON);
//what should i add here
if(((0x8000 ==(0x8000 & GetKeyState(16))&& !caps)) || ((0x8000 ==(0x8000 & GetKeyState(16))&& caps)))
{
if(lpDrawItemStruct->CtlID==IDC_BUTTON49)
::DrawText(lpDrawItemStruct->hDC,"!",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON45)
::DrawText(lpDrawItemStruct->hDC,"_",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON39 )
::DrawText(lpDrawItemStruct->hDC,"\"",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON44)
::DrawText(lpDrawItemStruct->hDC,"<",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON46)
::DrawText(lpDrawItemStruct->hDC,">",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON47)
::DrawText(lpDrawItemStruct->hDC,"?",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON48)
::DrawText(lpDrawItemStruct->hDC,")",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON50)
::DrawText(lpDrawItemStruct->hDC,"@",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON51)
::DrawText(lpDrawItemStruct->hDC,"#",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON52)
::DrawText(lpDrawItemStruct->hDC,"$",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON53)
::DrawText(lpDrawItemStruct->hDC,"%",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON54)
::DrawText(lpDrawItemStruct->hDC,"^",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON55)
::DrawText(lpDrawItemStruct->hDC,"&",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON56)
::DrawText(lpDrawItemStruct->hDC,"*",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON57)
::DrawText(lpDrawItemStruct->hDC,"(",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
if(lpDrawItemStruct->CtlID==IDC_BUTTON59)
::DrawText(lpDrawItemStruct->hDC,":",1,&lpDrawItemStruct->rcItem, DT_SINGLELINE| DT_VCENTER|DT_CENTER);
}
Request to all to continue this
|
|
|
|
|
I am trying to encrypt a video file (any format)using my own algorithm. I want to know how could I get the data of video file. Is there any class or library available that can give me direct access to video file data. Is there any available DirectShow Class Library available for directly accessing video data?
I don't want to change the header of the file. Just need direct access to the video data (in binary) so that i can apply my encryption algorithm on it.
Thanks
Naveed
|
|
|
|
|
If you wish to use DirectShow, then the method is to generate a playback graph that first has a source filter (the video file), then possible decoding filters to get raw video data, then a Sample Grabber filter, which allows access to the samples passing through the graph and a Null Renderer filter, which will discard the original samples.
Then, using the Sample Grabber, grab every frame of the video, pass it through your encoding algorithm, and manually write a file. The filter provides a callback for an user-specified function whenever it receives a sample, so no data will be lost. Unfortunately, as far as I know, you cannot reinsert your encoded samples back into the same graph. You must manually write a file header and the actual file.
The final (and most difficult) option is to write a DirectShow filter using your algorithm. This is very similar to writing an encoding/decoding filter. The raw data comes from the input pin, is encrypted, and passes from the output pin. You can then insert an AVI Mux filter and a file writer filter to have a fully functioning encrypting graph. This is the most efficient way, but may require some learning and trial & error procedures.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
I use lex and yacc generate 3 files and want to ues those files in my MFC project.
however, it doesn't work.
How to connect them?
|
|
|
|
|
Chenbuaa wrote:
however, it doesn't work.
What exactly is it that does not work?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello:
I have an application that makes heavy use of many double buffered images that are dynamicly updated in real time (GDI). I have created the compatible DC's and CBitmaps. I think that I have properly closed all resources as soon as I use them. However when I reach around 64 of these double buffered DC's my application hard-crashes windows with a reboot, and a message in system font that resources have been used up. Is there a limit to the DC stored or is this a symptom of something I am not releasing properly?
|
|
|
|
|
There is a limit to how many DCs can be created at one time, and you just found it . You must use as few DCs as possible, and release them as soon as you're finished with them. You don't need a single DC per bitmap, just select the bitmaps into one DC as you need them. I recommend creating and destroying the compatible DC each time in your drawing method, rather than creating and storing it for later use.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Does DrawDragRect go by current window location or total scroll window location? Cause right now when I scroll it would continue to display page 1 stuff.
|
|
|
|
|
I was fairly disappointed with DrawDragRect - you must do alot of work yourself and clean up once the mouse button is released. There is a function to translate and scale co-ordinates relative to the upper left corner of the client window, which I remember you must use.
|
|
|
|
|
Any chance you know which function is that? I am searching for it I can't find it.
There aren't too many DrawDragRect example floating around on the net.
|
|
|
|
|
I'm trying to print an image with DrawImage (GDI+ library).
graphics.DrawImage(pImage, rfDraw, rfPic.X, rfPic.Y, rfPic.Width, rfPic.Height, UnitPixel);
The graphics object is constructed with a printer device context.
The <rect>rfPic rectangle is the source area to draw from, e.g. (0, 0, 1000, 800) pixels. The rfDraw rectangle is the destination area to draw to, e.g. (100, 100, 6100, 4900) pixels. On a 600 x 600 dpi printer, this should result in a 10 x 8 inch image.
However, the image is blown up to gigantic proportions, so I only see a small magnified portion of the image. Can someone tell me why?
Drawing to screen works fine (same code, different values). I tried other unit values, setting the page scale and a lot of other things. No luck.
Can someone help me please?
Thanks,
giannibal
|
|
|
|
|
Hi,
I have a pointer to some raw pixel data and I'd like to display it to the screen and then allow the user to click on a point and get the image's pixel coordinates of the mouse click. Also because the images are big I'd like to have a scroll bar so that you can show a 1:1 image in a smaller window. Also ideally i'd like the window doing this to be a dialog in modal mode.
I can use the WM_PAINT message with SetDIBitesToDevice(...) in WM_PAINT of a dialog box to solve some of those problems, however then I don't get the scroll bars. I tried creating my own control from:
http://www.codeproject.com/miscctrl/customcontrol.asp[^]
tutorial, but it's not going too well and I realized that implementing my own scroll bars will be hard.
Any help is appreciated.
|
|
|
|
|
|
There is no compression on an 8 bit image, but it is paletized. Do you have a palette in your data ? If not, then that will be the problem. Can you do other 8 bit or less images OK ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Turn your bits into a DIBSection, then just draw that to the screen in WM_PAINT, taking into account the positions of the scroll bars.
also take the scroll positions into account when a user clicks.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I'm basically trying to output *.ppm and *.pgm files. The file format of ppm is a simple header followed by 24 bits for RGB for each pixel. For the pgm it's a simple header followed by 8 bits per pixel.
I can read and display the ppm files using this bit of code:
<br />
BITMAPINFO bi ;<br />
bi.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );<br />
bi.bmiHeader.biWidth = m_nWidth;<br />
bi.bmiHeader.biHeight = -m_nHeight;
bi.bmiHeader.biPlanes = 1;<br />
bi.bmiHeader.biBitCount = 24;<br />
bi.bmiHeader.biCompression = BI_RGB;<br />
bi.bmiHeader.biSizeImage = ::abs( m_nWidth*m_nHeight ) * 3;<br />
bi.bmiHeader.biXPelsPerMeter = 100;<br />
bi.bmiHeader.biYPelsPerMeter = 100;<br />
bi.bmiHeader.biClrUsed = 0;<br />
bi.bmiHeader.biClrImportant = 0;<br />
<br />
::SetDIBitsToDevice(<br />
dc.GetSafeHdc(),<br />
0, <br />
0,<br />
m_nWidth, <br />
m_nHeight,<br />
0, <br />
0,<br />
0, <br />
m_nHeight,<br />
m_pImage, <br />
&bi, <br />
DIB_RGB_COLORS );<br />
However this doesn't work for the pgm images. I don't know what header to set or how to display it unless I physically take the data I loaded in the pointer and insert R=G=B=original grayscale data.
|
|
|
|
|
Hi Guys
I want to prevent my app getting terminated by the taskmanager. I saw some examples but they are using dlls that you have to pay for. So I informed myself a bit about that. I figured out that i've to use SetWindowHookEx. And there we are at my first problem: What type of Hook should i use ? i prefered WH_CALLWNDPROC. And how do i have to realize the main loop ? Is it a function that i get with the hook ? I'm never used hooks before, but i'm sure with some help i could do it.
MFG
RedDragon
P.S.: The code will never be used to cause any damage to hard- or software. I'm working on a program which controls pupil pc's.
Unix and C are the ultimate computer viruses.
|
|
|
|
|
|
Yeah i see. I read this articles, too. But it is POSSIBLE. A programmer already done so. You can find the demo app on: http://www.madexcept.com/ under c++ and then go to MadCodeHook. Yeah you can come with this argument: Why don't you even this code ? Well, how could i get better when i just copy or use dlls from others ?
MFG
RedDragon
P.S: Excuse my bad english
Unix and C are the ultimate computer viruses.
Visit me: www.programming.info.ms
|
|
|
|
|
If your application is has a window, use classview and add the windows message handler: OnQueryEndSession. In the body, return false, and your application will prevent any shutdown that does not use the EWX_FORCE switch.
Himanshu
|
|
|
|
|