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
D

Drakesal

@Drakesal
About
Posts
23
Topics
10
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Elevate Process from user to Admins Rights without UAC Elevation
    D Drakesal

    Hi i am trying to develop an application with following features: The program starts in an user context, and during execution it will acquire admins rights, can i accomplish this without the UAC Elevation? If yes can you drive me to article that explains it? Thanks in advance

    C / C++ / MFC question

  • Waiting for open files
    D Drakesal

    Right now you have understood i was looking for directory change but i haven't found something as example to test the possibility, if you can show me some example please

    C / C++ / MFC help

  • Waiting for open files
    D Drakesal

    I have tried for all day and i have always the same for first file is all ok and from second the system do not wait, becouse my english is not perfect like yours i luckly found an user response to show you so i can be more specific: "What happens depends on the application that is registered to open PDF or JPG files. If you open the documents in an SDI application, then every CreateProcess() call returns a process handle for an application, which you can wait for - this will return when the application editing the document closes. If however an application is limited to a single instance, then every further call will return as soon as the new instance has passed the data to the first instance (which will usually open the document in a new frame), and then has exited. I think that is what happens in your case, probably you are using Acrobat Reader to open the PDF files" The problem for me is clear the question is: it's possibile manage this problem using some workaround?

    C / C++ / MFC help

  • Waiting for open files
    D Drakesal

    i try to understand you i need to do this: open 3 pdf with WaitForMultipleObjects(Array.GetCount(), Array.GetData(), FALSE, INFINITE); and after user modifed pdf i need to save and delete from TMP folder. if i use FALSE like i show you first i obtain the right signaled file number but the file was deleted without open becouse WaitForMultipleObjects do not block the execution maybe becouse the acrobat is already loaded

    C / C++ / MFC help

  • Waiting for open files
    D Drakesal

    Hi thanks for response i have already tried about WaitForMultipleObjects but the function wait until all opened files will be closed if i flag it TRUE. If a flag it FALSE become similar to WaitForSingleObjects

    C / C++ / MFC help

  • Waiting for open files
    D Drakesal

    Hi i am developing an application CListCtrl based, which can open more files listed inside, to do this i did thread for every file will be clicked, the problem is when i close a file i'd like to do some check operations on file, but using WaitForMultipleObjects it wait first i close all files and then perform the operations, with WaitForSingleObjects it wait only for first file and ignore the others. I'd like so: 1) i open the file1.pdf - the program wait. 2) i open the file2.pdf - the program wait. 3) i close the file "file1.pdf" - the program perform operations on file1 (the file2.pdf is waiting) Please i hope somebody can help me Giovanni

    C / C++ / MFC help

  • About SetFocus in Doc/View Architecture
    D Drakesal

    I have made a program with Outlookbar Class and a clistview class now, i'd like when i click in the Outlookbar automatically the view will take the focus. I have tried with SetFocus(). but nothing. Can you indicate me the correct procedure? i start with this line to geto pointer to the view

    CView* pView = (CView*)GetActiveView();

    It will not take you many time, so thanks in advance. Giovanni

    C / C++ / MFC architecture question

  • Crypto API Question
    D Drakesal

    I am crazying with a problem with the following function:

    CStringA EncryptDecryptString(CStringA szString, BOOL bEncrypt)
    {
    HCRYPTPROV hCryptProv = NULL;
    LPCWSTR keyContainer = _T("MyKeyContainer");

       if(CryptAcquireContext(&hCryptProv,keyContainer,NULL,PROV\_RSA\_FULL,0))
             if (GetLastError() == NTE\_BAD\_KEYSET)
                CryptAcquireContext(&hCryptProv,keyContainer,NULL,PROV\_RSA\_FULL,CRYPT\_NEWKEYSET);
    
       HCRYPTHASH hHash = NULL;
       TCHAR szPassword\[11\]         = \_T("Password");
    
       if(CryptCreateHash(hCryptProv,CALG\_MD5,0,0,&hHash))
    {
             if(!CryptHashData(hHash,(BYTE \*)szPassword,wcslen(szPassword),0))
             {
                    // reset hash object to NULL
                    CryptDestroyHash(hHash);
                    hHash = NULL;       
             }
    }
    
       HCRYPTKEY hKey = NULL;
    
       CryptDeriveKey(hCryptProv,CALG\_RC4,hHash,0x00800000,&hKey);
    
       DWORD length= szString.GetLength() + 1;
       BYTE \* cipherBlock= (BYTE \*)malloc(length);
       memset(cipherBlock, 0, length);
       memcpy(cipherBlock, szString, length -1);
    
       if (bEncrypt)
             CryptEncrypt(hKey,0,TRUE,0,cipherBlock,&length,length);
       else
             CryptDecrypt(hKey,0,TRUE,0,cipherBlock,&length);
    
       CStringA szOutString(cipherBlock);
    
       if(cipherBlock) 
             free(cipherBlock); 
       if(hKey)
             CryptDestroyKey(hKey);
       if(hHash) 
          CryptDestroyHash(hHash);
       if(hCryptProv) 
          CryptReleaseContext(hCryptProv,0);
    
       return szOutString;
    

    }

    It's all ok with function, but sometimes when string is very very long during the Decryption i have only a part of string becouse the allocated memeory is not enought. How can i alloc the correct amount of memory during the decryption phase?

    C / C++ / MFC question cryptography json performance help

  • CMenu with Bitmap icon
    D Drakesal

    I done it!!!! I did so: 1) OnCreate i put this as you told me:

    CMFCToolBar::AddToolBarForImageCollection(IDR_MAINFRAME_256);

    1. in Contextmenu i add these lines:

      CMFCPopupMenu* PopupMenuFolders = new CMFCPopupMenu();

      //Mi serve controllare prima che esce il menu per eventualmente eliminare voci del menu non permesse.
      CheckWhatCanIDo(ExtractFullTreePath(htSelectedTreeItem),MainComputerinfo.szSid,m_bUserAuthorizations);

      PopupMenuFolders->InsertItem(CMFCToolBarMenuButton(ID_POPUP_FOLDERS_TREE_1, NULL, 0, _T("Item 1")));

      PopupMenuFolders->InsertItem(CMFCToolBarMenuButton(ID_POPUP_FOLDERS_TREE_2, NULL, 1, _T("Item 2")));

      PopupMenuFolders->InsertItem(CMFCToolBarMenuButton(ID_POPUP_FOLDERS_TREE_3, NULL, 2, _T("Item 3")));

      PopupMenuFolders->Create(this, point.x, point.y, NULL);

    So you use directly the Toolbar Images. Thanks all ;) Giovanni

    C / C++ / MFC graphics algorithms help tutorial question

  • CMenu with Bitmap icon
    D Drakesal

    Can you show me in code if is possible?

    C / C++ / MFC graphics algorithms help tutorial question

  • CMenu with Bitmap icon
    D Drakesal

    I need a popup menu with an icon 16x16 on the left and the text on the right, for every menu item.

    C / C++ / MFC graphics algorithms help tutorial question

  • CMenu with Bitmap icon
    D Drakesal

    Hi i am searching many information about this, but i only find complex code. I simply need a context menu with icons. Now i post my code can you help me to complete?

    CMenu Menu;

    Menu.CreatePopupMenu();

    Menu.AppendMenuW(MF_STRING,ID_POPUP_1,(LPCTSTR)_T("Item 1"));

    Menu.AppendMenuW(MF_STRING,ID_POPUP_2,(LPCTSTR)_T("Item 2"));

    Menu.AppendMenuW(MF_STRING,ID_POPUP_3,(LPCTSTR)_T("Item 3"));

    theApp.GetContextMenuManager()->ShowPopupMenu(Menu, point.x, point.y, this, TRUE);

    I have seen on MSDN i have to use this:

    // Load bitmaps from resource. Both m_CheckBitmap and m_UnCheckBitmap
    // are member variables of CMainFrame class of type CBitmap.
    ASSERT(m_CheckBitmap.LoadBitmap(IDB_CHECKBITMAP));
    ASSERT(m_UnCheckBitmap.LoadBitmap(IDB_UNCHECKBITMAP));

    // Associate bitmaps with the "Bitmap" menu item.
    CMenu* mmenu = GetMenu();
    CMenu* submenu = mmenu->GetSubMenu(4);
    ASSERT(submenu->SetMenuItemBitmaps(ID_MENU_BITMAP, MF_BYCOMMAND,
    &m_CheckBitmap, &m_UnCheckBitmap));

    But i think my situation is more easy than example, but maybe i have problems to merge the two code parts, please can you help me i don't think take you more time. Thanks very much.

    C / C++ / MFC graphics algorithms help tutorial question

  • CMFCOutlookBar cannot return to pane 0.
    D Drakesal

    Hi i am writing a simple app with doc/viw architecture, now i have to buttons in the Outlook bar "Folders" and "Calendar" now i want that when restart the app the selected pane will be always the 0 -> "Folders" now i tried this:

    CMFCOutlookBarTabCtrl\* pOutlookBar = (CMFCOutlookBarTabCtrl\*)m\_wndNavigationBar.GetUnderlyingWindow();
    
    pOutlookBar->SetActiveTab(0);
    

    After this nothing happen. Why this? i wait for your precious response :) Giovanni

    C / C++ / MFC architecture question

  • How manage the lose focus from CListCtrl Control
    D Drakesal

    You are a MASTER!!!! you solved me the problem THANKS THANKS!!!! :thumbsup::thumbsup::thumbsup:

    C / C++ / MFC help

  • How manage the lose focus from CListCtrl Control
    D Drakesal

    No i need to draw gray when i leave the row selected but i click on another control.

    C / C++ / MFC help

  • How manage the lose focus from CListCtrl Control
    D Drakesal

    Hi i am doing a program with a clistctrl with custom draw and i have custom highlight color bar. Now my problem is when i am with mouse on CListCtrl the bar is color i wish, when i leave to go on other control i don't know how change the color in gray of the highlight bar, i post the code for you:

    void CPubFoldersView::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
    {
    NMLVCUSTOMDRAW* pCD = (NMLVCUSTOMDRAW*)pNMHDR;
    int nRow = pCD->nmcd.dwItemSpec;
    CListCtrl& m_MainTable = GetListCtrl();
    CString szInEvidence;

    //Remove standard highlighting of selected (sub)item.
    pCD->nmcd.uItemState = CDIS\_DEFAULT;
    
    if (VirtualRowArray.GetCount())
    	szInEvidence=VirtualRowArray\[nRow\].Field\[4\];
    
    switch(pCD->nmcd.dwDrawStage)
    {
    	case CDDS\_PREPAINT:
    		\*pResult = CDRF\_NOTIFYSUBITEMDRAW;
    		break;
    		
    	case CDDS\_ITEMPREPAINT:
    		\*pResult = CDRF\_NOTIFYSUBITEMDRAW;
    		break;
    		
    	case CDDS\_ITEMPREPAINT|CDDS\_SUBITEM:
    	{
    		if (m\_MainTable.GetItemState(nRow, LVIS\_SELECTED)==LVIS\_SELECTED && m\_MainTable.GetItemState(nRow, LVIS\_FOCUSED)==LVIS\_FOCUSED)
    		{
    			pCD->clrTextBk	= RGB(167,205,240);    //Selected color
    			\*pResult = CDRF\_NEWFONT;
     		}
    		if (m\_MainTable.GetItemState(nRow, LVIS\_SELECTED)==LVIS\_SELECTED && m\_MainTable.GetItemState(nRow, LVIS\_FOCUSED)!=LVIS\_FOCUSED)
    		{
    			pCD->clrTextBk = RGB(197, 206, 216);    //Only focused color
    			\*pResult = CDRF\_NEWFONT;
     		}
    	}
    		break;
    
    	default:
    		\*pResult = CDRF\_DODEFAULT;
    }
    

    }

    C / C++ / MFC help

  • CLongBinary Limited to 255 Bytes
    D Drakesal

    I finally resolved the issue. I explain to you. 1) Download last SQL server driver. 2) Rebind/Recreate the CRecordset, so it bind with varbinary(max) -> CBYTEARRAY 3) In Recordset Class in the line : RFX_Binary(pFX, _T("[FileData]"), m_FileData,15360000); increase the last parameter to desidered max dimension (15MB in my case). 4) Write this simple code:

    		CFile cfFileToSave(szPathFileToOpen,CFile::modeRead);
    		rsAttachments.m\_FileData.SetSize((INT\_PTR)cfFileToSave.GetLength());
    		cfFileToSave.Read(rsAttachments.m\_FileData.GetData(),(UINT)cfFileToSave.GetLength());
    		cfFileToSave.Close();
    
    		rsAttachments.SetFieldDirty(&rsAttachments.m\_FileData,TRUE);
    		rsAttachments.SetFieldNull(&rsAttachments.m\_FileData,FALSE);
    
    		rsAttachments.Update();
    

    All done thanks all :thumbsup:

    C / C++ / MFC help database sql-server sysadmin performance

  • CLongBinary Limited to 255 Bytes
    D Drakesal

    Ok already posted the code the problem occur in the moment i call Update, and when the file is greater than 255kb

    C / C++ / MFC help database sql-server sysadmin performance

  • CLongBinary Limited to 255 Bytes
    D Drakesal

    i am a novice with a DB programming i have put now a CDBException that return me this: m_strStateNativeOrigin = "State:37000,Native:7125,Origin:[Microsoft][ODBC SQL Server Driver][SQL Server] State:S1000,Native:0,Origin:[Microsoft][ODBC SQL Server Driver] It's good this?

    C / C++ / MFC help database sql-server sysadmin performance

  • CLongBinary Limited to 255 Bytes
    D Drakesal

    Hi all I am writing a program to submit some files in a SQL server 2012 the problem is: when the file size is around 255 KBytes it's all ok, but when the file is greater there is an error on "RecordSet.Update() phase. The error is : "The Pointer Value type Text, NText or image conflicts with the specified column name. ..." The Column is declared in table as varbinary(max) the code is:

    	CFile file(szPathFileToOpen, CFile::modeRead);
    	ULONGLONG filelen = file.GetLength();
    
                rsAttachments.AddNew();
    
    	rsAttachments.m\_AttachmentsID=szUniqueID;
    
    	rsAttachments.m\_FileName=m\_ListAttached.GetItemText(0,0);
    
    	GlobalFree( rsAttachments.m\_FileData.m\_hData );
    
    	if((rsAttachments.m\_FileData.m\_hData=GlobalAlloc(GMEM\_MOVEABLE,filelen))==NULL) 
    	{
    		AfxMessageBox(\_T("memory error"));
    	}
    
    	LPVOID pVoid = NULL;
    	if((pVoid=GlobalLock(rsAttachments.m\_FileData.m\_hData))== NULL) 
    	{
    		AfxMessageBox( \_T( "memory error" ));
    	}
    
    	file.Read(pVoid, filelen);
    
    	rsAttachments.SetFieldDirty( &rsAttachments.m\_FileData, TRUE );
    	rsAttachments.SetFieldNull( &rsAttachments.m\_FileData, FALSE );
    
    	rsAttachments.m\_FileData.m\_dwDataLength=GlobalSize(rsAttachments.m\_FileData.m\_hData );
    
                rsAttachments.Update();
    
    	GlobalFree( rsAttachments.m\_FileData.m\_hData );
    

    Thanks in advance to the angel will help me. Giovanni

    C / C++ / MFC help database sql-server sysadmin performance
  • Login

  • Don't have an account? Register

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