Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
G

gabbana

@gabbana
About
Posts
40
Topics
13
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Problem with retrieveing number of characters in a multiline edit control
    G gabbana

    Okay i found the error. I think the wparam needs the offset of the char in the complete edit field. So I first sent the EM_LINEINDEX message and now I thinks its working.

    C / C++ / MFC help question

  • Problem with retrieveing number of characters in a multiline edit control
    G gabbana

    Hi, I have some problems with the edit control. I want to count the chars if it, but the message i send to the control only receives the right character num for the first line. For exmaple. The first line can have 60 chars. If I only enter 50 or so, the message gives me the right count. If I then enter a longer text, so that the first line have all the 60 chars and the second line have only 30 chars, then the message returns also a number of 60 chars for the second line, but why ? Where is the problem ? My line:

    dwChars = (DWORD)SendDlgItemMessage(hwnd,IDC_INPUT,EM_LINELENGTH,(WPARAM)3,(LPARAM)0);

    I hardcoded the line 3 here, normally I am going through a for loop.

    C / C++ / MFC help question

  • MD5 - different results
    G gabbana

    wow, Thank you. It was the null terminator.

    C / C++ / MFC help cryptography php json tutorial

  • MD5 - different results
    G gabbana

    Hy, I have my next problem. I am trying to get an md5 hash from an string (i am using "hello" in this example) The problem is, that the CryptoAPI gives me a different key than the md5 function from PHP. I think MD5 is MD5 so both should give me the same result. Here is my Code for the crypto api -> error() only shows Error Nr.: id as a small help for me. The ByteToStr function is the same ByteToStr function which is in the MSDN.

    HCRYPTPROV	hProv	= NULL;
    HCRYPTHASH	hHash	= NULL;
    BYTE	\*pbKey	=  (BYTE\*)"hello";
    DWORD	dwKeyLen	= strlen((char\*)pbKey)+1;
    DWORD	dwHashLen	= 0;
    BYTE	pbOut\[16\];
    
    if(!CryptAcquireContext(&hProv,NULL,NULL,PROV\_RSA\_FULL,0))	Error(1);
    if(!CryptCreateHash(hProv,CALG\_MD5,0,0,&hHash)) Error(2);
    if(!CryptHashData(hHash,pbKey,dwKeyLen,0)) Error(3);
    if(!CryptGetHashParam(hHash,HP\_HASHVAL,NULL,&dwHashLen,0)) Error(4);
    if(!CryptGetHashParam(hHash,HP\_HASHVAL,pbOut,&dwHashLen,0)) Error(5);
    
    
    LPCSTR lpMsg = new char\[100\];
    
    ByteToStr(dwHashLen,&pbOut,(LPSTR)lpMsg);
    
    MessageBoxA(NULL,lpMsg,"hihi",0);
    
    delete lpMsg;
    CryptDestroyHash(hHash);
    CryptReleaseContext(hProv,0);
    

    Thanks for help. bye, gabbana

    C / C++ / MFC help cryptography php json tutorial

  • Need some Bits/Bytes and Types information
    G gabbana

    Ahh okay great. Thank you very much. I think I will try a bit and see what the debugger shows to become a better "feeling" of how something of that happens so that I know "Aahh, I have an error with the memory allocation".

    C / C++ / MFC help question database data-structures performance

  • Need some Bits/Bytes and Types information
    G gabbana

    Oh I see the first two answers now. Thank you very much but it would be great if you also confirm what I say in the last post. I think the unicode stuff I mentioned is right, juhuu.

    C / C++ / MFC help question database data-structures performance

  • Need some Bits/Bytes and Types information
    G gabbana

    Okay, now I think i found some information. Lets start with Bits and Bytes: A BIT can be 1 or 0. So we have 2 options A BYTE contains 8 Bits. So we have 2^8 possible option (ASCII/ANSI) So we have all the 256 chars. A WORD contains 16 Bits (2BYTE) A WCHAR (wide char) contains also 16bits (2BYTE) -> chinese languag and so on need 2 Bytes for one char. A Pointer (I said its normally a void point but that was wrong) is normally a pointer to a specific datatype, for example WCHAR *buf -> means we have a Pointer which points to ONE WCHAR somewhere in memory (as long as we allocate space) So now we allocate space: *buf = new WCHAR[16]; This means we allocate 16 bits per char, so we have allocated 2*16 bytes = 32 bytes which means 2^32 bits. So if we use the example with edit field, we get an integer (the length) and convert it to a WORD. BECAUSE the edit field must return something >0 we CAN convert it to an unsigned integer, a WORD right? -> Now why do we need the following? *((LPWORD)buf) = length And why does *(buf) = (WORD)length also works ? So we know that WCHAR contains 2Bytes. A WORD also contains 2Bytes. So the point normaly shows to the firt wchar which is also a WORD in this example. So we can easily move the length to this location. Right ? But why the first way ? So it could be that if we does not using unicode, the pinte would only show to the first ONE byte in the memory. And then we need to convert it it first to an LPWORD to be sure the pointer shows to the FIRST 2Bytes, a WORD in memory. And so it works. I hope its not too long and someone can confirm my explanation. Thank you very much. bye, gabbana

    C / C++ / MFC help question database data-structures performance

  • Need some Bits/Bytes and Types information
    G gabbana

    Hy, I am still having problem handling some data types and the data itself in memory and so on. For example: For getting the text of an edit control (winapi) requires to create a buffer with enaugh space. I did (unicode) for example: length is from the type of WORD in the example, but i used length as an integer. TCHAR *buf = new TCHAR[length+1]; So now it says the FIRST WORD needs to have the length of the string in the edit field, which I retrieved before. The example shows: *((LPWORD)buf) = length; However, when I use my way: *(buf) = length it ends in the same result. So, my question is whats so special in the way how msdn do it? ----- And then, did i understand the line right ? Here is my explanation: In memory we have allocated space for the variable buf. The length is the length of TCHAR * mylength(the variable) But in memory it is handled as "we need xx bytes" right? Then *(buf) points to the first byte (in array it is index 0) But because we need the first word, we convert the normal pointer (i think normal is a void pointer) to an pointer of a WORD. So now the index 0 for examples is exactly 1 WORD. Then we write the length variable which is also a WORD to the location. Is this right or do I misunderstand something? ---- And why is my way *(buf) = length also working? I hope everybody understand whats my problem. Thank you for help. bye, gabbana

    C / C++ / MFC help question database data-structures performance

  • SCI_GETTEXT - Scintilla, how do I get the text ?
    G gabbana

    Does nobody has an idea how to fix the problem ? By the way: Is Scintilla a good choice, or would it be better to use the rich text edit control and write own functions to extent it, because i am learning c++, and probably it would be better for learning.

    C / C++ / MFC question debugging help

  • SCI_GETTEXT - Scintilla, how do I get the text ?
    G gabbana

    Okay, now I am using delete. The stack corrupted message already exists. The error must be the memset, because if i delete that line I am not getting an error. The problem with the chinse chars already exists! hWndEditor is the handle to sintilla text control. I declared it in my header file HWND hWndEditor and created the control in the WM_CREATE message:

    hWndEditor = CreateWindowEx(0,
    _T("Scintilla"),
    _T(""),
    WS_CHILD | WS_VISIBLE,
    0,
    0,
    500,
    500,
    hWnd,
    (HMENU)1,
    (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
    NULL);

    EDIT: Yes i send the following message in WM_CREATE after the control is created: SendMessage(hWndEditor, SCI_SETKEYSUNICODE, true, 0);

    C / C++ / MFC question debugging help

  • SCI_GETTEXT - Scintilla, how do I get the text ?
    G gabbana

    I get the same error. What I found now is, that if i only allocate memory with your code and removing the memset and free functions I get no error, but the MessageBox and the gives me some crazy char like chinese. (I think I should mention that I use UNICODE)

    C / C++ / MFC question debugging help

  • SCI_GETTEXT - Scintilla, how do I get the text ?
    G gabbana

    Okay, but without luck. Iam not sure what the error exactly is, but if I have a breakpoint at the last SendMessage and look in the Debugger &data have a value of 0x00... and Bad Ptr And the MessageBox is empty. The code looks like this:

    		UINT length = SendMessage(hWndEditor, SCI\_GETLENGTH, 0, 0);
    		TCHAR \*data;
    		memset(&data, 0, sizeof(TCHAR)\*length+1);
    		length = SendMessage(hWndEditor, SCI\_GETTEXT,length+1,(LPARAM)data);
    		MessageBox(NULL,data,L"Test",0);
    		free(data);
    

    At the end of the function I also get this error: Stack around the variable 'data' was corrupted

    modified on Sunday, October 26, 2008 11:16 PM

    C / C++ / MFC question debugging help

  • SCI_GETTEXT - Scintilla, how do I get the text ?
    G gabbana

    Hmm, I get an error: cannot convert from TCHAR* to UINT And the last parameter i needed to cast (LPARAM)data.

    C / C++ / MFC question debugging help

  • SCI_GETTEXT - Scintilla, how do I get the text ?
    G gabbana

    Hi, I am wondering how I can get the text from an scintilla text control ? This is my code, but the debugger says that data has a bad pointer and I have no text in it.

                        TCHAR \*data;
    		UINT nLength;
    		nLength = SendMessage(hWndEditor,SCI\_GETLENGTH,0,0);
    
    		// allocate buffer;
    
    		memset(&data,0,sizeof(TCHAR)\*nLength+1);
    
    		// get the data
    
    		data = (TCHAR\*)SendMessage(hWndEditor, SCI\_GETTEXT,nLength+1,0);
    
    		// show the data
    
    		MessageBox(NULL,data,L"MyApp",0);
    
    		// clear the buffer
    		free(data);
    

    Thanks for help. bye, gabbana

    C / C++ / MFC question debugging help

  • MoveFile: Access denied ???
    G gabbana

    The files moving from C:\myfile.txt to C:\myapp\txt So its my own directory...

    C / C++ / MFC question help

  • MoveFile: Access denied ???
    G gabbana

    Hi, I have a big problem. I am trying to use the simple method MoveFile but getting Error code 5: Access denied. I have Windows Vista and UAC enabled. If I right click on the app and select "Run as administrator" -> everything works fine. My problem is, many users have normal accounts and don't run apps as an administrator. So my question is how can i implement the feature to move the file as a normal user? Thanks. bye, gabbana

    C / C++ / MFC question help

  • Rect flickrs outside of the the app area
    G gabbana

    Okay i solved the problem with the double buffering system. I created a new DC and a Bitmap and draw into this dc and made an bit block transfer at the end into the right DC.

    Graphics help

  • Graphics how to start ????
    G gabbana
    1. Yes its possible -> creating own controls 2) c++ :) 3) You cannot compare game development with graphic development, because the first also includes thinks like AI,..., my best way would be start with GDI (GDI+) and then begin with Direct3D.
    Graphics help c++ delphi graphics game-dev

  • Rect flickrs outside of the the app area
    G gabbana

    Hello, I have the following problem: I painted a rectangle with a text outside of my app on the screen in the WM_PAINT message. The Problem is that it flickrs very hard. The code I use:

    	hdc = GetDC(NULL);
    	SelectObject(hdc, GetStockObject(WHITE\_BRUSH));
    	RoundRect(hdc, 10, 10, 100, 40, 9, 9);
    	rc.left = 10;
    	rc.top = 10;
    	rc.right = 100;
    	rc.bottom = 40;
    	SetBkColor(ps.hdc, RGB(255,255,255));
    	DrawText(hdc,L"Hello",5, &rc, DT\_CENTER | DT\_VCENTER | DT\_SINGLELINE);
    	ReleaseDC(hWnd,hdc);
    

    I also tried using the WM_NCPAINT message but the it destroys the complete app frame. Thanks for help. bye, gabbana

    Graphics help

  • Creating an iso Image
    G gabbana

    Are there no other information available ? I spend about 2hours again searching different keywords with google without luck. So if someony have an idea, please help me! Thanks again, bye, gabbana

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups