|
It doesn't help. Actually SHGFP_TYPE_CURRENT is defined 0.
Did you succeed in retrieving the "My Computer" path? What did the function return?
Sincerely,
|
|
|
|
|
hmm, I get the same results. I think the reason is that CSIDL_DRIVES does not have a real directory path. There must be a way of doing it, but I'm not sure what it is. The closest that I can suggest right now is to use CSIDL_DESKTOPDIRECTORY which does have a real path and it shows "My Computer" as an item in that "directory"
the only other suggestion I have is to hook the open file dialog and find the id of the "My computer" button and click it programmatically.
good luck.
|
|
|
|
|
here's some code that'll do what you want. paste it into a .cpp file and compile and run.
#define _WIN32_WINNT 0x0501
#define STRICT
#include <windows.h>
#include <shlobj.h>
#include <shfolder.h>
#include <tchar.h>
UINT_PTR __stdcall OpenFileHook(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
if (msg == WM_NOTIFY)
{
HWND parent = ::GetParent(hwnd);
HWND tbctl = ::GetDlgItem(parent, ctl1);
LRESULT count = ::SendMessage(tbctl, TB_BUTTONCOUNT, 0, 0);
LRESULT result;
for (int button = 0; button < count; ++button)
{
TCHAR buttonText[1024];
TBBUTTON buttonData;
::ZeroMemory(buttonText, sizeof(buttonText));
::ZeroMemory(&buttonData, sizeof(buttonData));
result = ::SendMessage(tbctl, TB_GETBUTTON, (WPARAM)button, (LPARAM)&buttonData);
result = ::SendMessage(tbctl, TB_GETBUTTONTEXT, (WPARAM)buttonData.idCommand, (LPARAM)buttonText);
if (result != -1 && _tcscmp(_T("My Computer"), buttonText) == 0)
{
if (0 == ::SendMessage(tbctl, TB_ISBUTTONCHECKED, (WPARAM)buttonData.idCommand, 0))
{
RECT rect;
::ZeroMemory(&rect, 0);
::GetClientRect(tbctl, &rect);
::PostMessage(tbctl, WM_LBUTTONDOWN, (WPARAM)MK_LBUTTON, MAKELPARAM(10, (rect.bottom - rect.top)/count * button));
::PostMessage(tbctl, WM_LBUTTONUP, (WPARAM)MK_LBUTTON, MAKELPARAM(10, (rect.bottom - rect.top)/count * button));
}
}
}
}
return (UINT_PTR)FALSE;
}
void main()
{
TCHAR fileBuffer[MAX_PATH * 10];
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof ofn);
ZeroMemory(fileBuffer, sizeof fileBuffer);
ofn.lStructSize = sizeof ofn;
ofn.lpstrFile = fileBuffer;
ofn.nMaxFile = sizeof(fileBuffer)/sizeof(fileBuffer[0]);
ofn.Flags = OFN_EXPLORER | OFN_ENABLEHOOK;
ofn.lpfnHook = OpenFileHook;
BOOL result = ::GetOpenFileName(&ofn);
}
hope this helps
-- modified at 12:40 Wednesday 14th December, 2005
had to fix the < and >
|
|
|
|
|
Thank you so much. Do we have another way instead of simulating mouse clicks?
Sincerely,
|
|
|
|
|
sorry, i tried, you'll have to take it from here.
|
|
|
|
|
I want to access the Read data from Screen Buffer and copy block data of the Buffer. Is it possible to achieve ? ... I want to read pixels but dont want to use the GDI functions ... Any help on it ?
Best Regards
|
|
|
|
|
Well you could use DirectX for this - I think DirectDraw has functions for something like this.
What are you trying to accomplish?
Do you want to render an image? Manipulate pixels?
If you want to manipulate pixels, you can do so in the WM_PAINT handler, get the HDC, create a new in memory DIB, manipulate the pixels of the DIB, and them bit blit this to your HDC, which will then be displayed on the screen.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
I dont want ti manipulate pixels. I mentioned I dont want to use GDI Functions. Are you sure DirectDraw has functions to read directly from Screen Buffer but is it fast enough ?
|
|
|
|
|
|
unescape ? you mean transforming things such as < into < ?
i believe that it is known in the CGI specifications, but not sure anymore...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
|
I didn't see your reply, saw that my question was incorrect and I found an answer.
We say "get a life" to each other, disappointed or jokingly. What we forget, though, is that this is possibly the most destructive advice you can give to a geek.
boost your code || Fold With Us! || sighist
|
|
|
|
|
Using the class "A set of ADO classes - version 2.20
By Carlos Antollini"
Trying to delete the current record set with the following code
if (pRs->IsOpen())
{
if (!pRs->IsEOF())
pRs->Delete();
}
the application craches with "unhandled exception in App.exe (kernel32.dll) 0xe06d7363:Microsodt C++ Exception.
What seems to be worng ?
sdancer
|
|
|
|
|
first put your code inside a try catch block:
<br />
try<br />
{<br />
}<br />
catch(_com_error &err)<br />
{<br />
AfxMessageBox(err.Description());<br />
}<br />
this will issue a message box with the error description returned by the ADO.Recordset object
no body can help you with this error with the information you supplied here!!
k_dehairy
|
|
|
|
|
thank you,
what more informations do you want to supply ?
Regards,
George
sdancer
|
|
|
|
|
The commands before Rs->IsOpen() is a Select query statement with outter Left join to other tables, and it works fine when i try to show them. It is just used in a ShowRecord Dialog with a Delete Button to delete the current record that is shown currently in the window objects. The MoveNext() & MovePrevious() buttons works just fine.
Regards,
George
sdancer
|
|
|
|
|
you still need to put your ADO code in a try .. catch blocks, just like what I pointed earlier.
then tell me what did the messagebox say.
generally speeking any code that deals with COM objects (like ADO) is better written inside try .. catch blocks.
k_dehairy
|
|
|
|
|
Trying the code you said, i receive the following error.
if (!pRs->IsEOF())
{
try
{
pRs->Delete();
}
catch(_com_error &err)
{
AfxMessageBox(err.Description());
return;
}
}
(I will make an english translation of the error code since i get it in Greeks)
"It was not possible to find the row for update.Its possible that some values have changed
since the last read."
What Seems to be the problem ? Below is the OnInitDialog() code and you can see the select query.
BOOL CBookProperties::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strSQL,strVal;
wchar_t buffer[20];
m_Sheet.AddPage (&m_SheetBasic);
m_Sheet.AddPage (&m_SheetDetails);
m_Sheet.AddPage (&m_SheetExtras);
m_Sheet.AddPage (&m_SheetPhoto);
m_Sheet.Create (this, WS_TABSTOP | WS_CHILD | WS_VISIBLE,WS_EX_CONTROLPARENT);
m_Sheet.SetWindowPos (NULL,0,100, 0,0,SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
//NEW Record
if (m_mode == NEW)
{
m_bNext.EnableWindow (FALSE);
m_bPrevious.EnableWindow (FALSE);
m_bPrint.EnableWindow (FALSE);
m_bDelete.EnableWindow (FALSE);
}
else
//EDIT VIEW Record
{
pAdoDb = new CADODatabase();
try
{
if (pAdoDb->Open(((CLibrarianApp*)AfxGetApp())->m_strConnection))
{
pRs = new CADORecordset(pAdoDb);
_ultow( m_lRecSQLCode, buffer, 10 );
//find the specific record
strSQL=_T("SELECT Books.*, Categories.CategoryDesc, Author1,PublishHouses.PublishHouseDesc ")
_T("FROM books LEFT OUTER JOIN Categories ")
_T("On Books.CategoryID=Categories.CategoryID LEFT OUTER JOIN PublishHouses ")
_T("On Books.CategoryID=PublishHouses.PublishHouseID ")
_T("WHERE BookID=") + CString(buffer) + " "
_T("ORDER BY title,author1,categoryDesc ASC");
if (pRs->Open(strSQL,CADORecordset::openQuery) )
{
SetRecordValues();
UpdateData(FALSE);
m_lAbsRecPosition=pRs->GetAbsolutePosition();
pRs->Close();
}
else
{
pRs->Close();
delete pRs;
}
//now set a global query to use with next & previous button
strSQL=_T("SELECT Books.*, Categories.CategoryDesc, Author1,PublishHouses.PublishHouseDesc ")
_T("FROM books LEFT OUTER JOIN Categories ")
_T("On Books.CategoryID=Categories.CategoryID LEFT OUTER JOIN PublishHouses ")
_T("On Books.CategoryID=PublishHouses.PublishHouseID ")
_T("ORDER BY title,author1,categoryDesc ASC");
if (pRs->Open(strSQL,CADORecordset::openQuery) )
{
pRs->SetAbsolutePosition (m_lAbsRecPosition);
}
else
{
pRs->Close();
delete pRs;
}
}
else
{
pAdoDb->Close();
delete pAdoDb;
}
}
catch (CADOException &e)
{
pRs->Close();
pAdoDb->Close();
delete pRs;
delete pAdoDb;
AfxMessageBox(_T("Data base error.");
m_bError=true;
m_bNext.EnableWindow (FALSE);
m_bPrevious.EnableWindow (FALSE);
m_bPrint.EnableWindow (FALSE);
m_bDelete.EnableWindow (FALSE);
m_bOk.EnableWindow (FALSE);
m_bUpdate.EnableWindow (FALSE);
m_bCreateNew.EnableWindow (FALSE);
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
sdancer
|
|
|
|
|
I found the error, It was the Outter Join from the query !
Regards,
sdancer75
|
|
|
|
|
I have some doubt on DC operations in Windows.
1. When we call Invalidate() for any window, does WM_PAINT is sent to all child windows and child of child windows as well??
2. I have created a Compatible memory DC for a picture control of a dialog box. I am painting something in the memoryDC and I am using BitBlt() to copy from the MemoryDC to the DC of the pic control in a regular interval. I am seeing when I am calling Invalidate() for the dialog box, the memory DC is also getting erased, the old painting is lost and a subsequent BitBlt() paints from the beginning (of the graph what I am drawing in the Memory DC). If I dont call Invalidate() old painting is not lost- why its happening, does Invalidate() also erase memory DC.
3. Does BitBlt() not require a subsequent call to Invalidate() to display the data in the window?? (unlike SetPixel() or Lineto() which require a subsequent call to Invalidate() or WM_PAINT to display the data in the screen) !!
Please help
Sanjoy Sinharoy
Software Enggineer
HCL Technologies
India
|
|
|
|
|
1. Depends on whether or not the WS_CLIPCHILDREN style is set on the owner window. Look at WS_CLIPSIBLINGS too.
2. Try calling Invalidate with the erase parameter set to false.
3. You do not want to call Invalidate afterwards. You might want to consider doing the bitblt in the WM_PAINT (OnPaint) handler.
hope this helps.
|
|
|
|
|
Still answer to this uestion is not clear:
1. Does BitBlt() require a subsequent call to Invalidate() to display the data in the window?? Or it is NOT required??
2. Does Invalidate() also erase memory DC. I have tested Invalidate(true) and Invalidate(false) both erases the previous content of the display. If I dont call Invalidate() old painting is not erased.
Please help
Sanjoy Sinharoy
Software Enggineer
HCL Technologies
India
|
|
|
|
|
Is there a way to programmatically create a PDF file in
visual c++? I can print to paper and Im hoping that
if I change a few lines somewhere that I can print an
electronic copy in PDF somehow.
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
there are some free libraries you can get that will generate PDFs. You can google for "PDF Generation"
There also are some PDF projects here on codeproject. Search the articles.
|
|
|
|
|
DanYELL wrote: Is there a way to programmatically create a PDF file in
visual c++? I can print to paper and Im hoping that
if I change a few lines somewhere that I can print an
electronic copy in PDF somehow
What about this :-
http://www.codeproject.com/tools/Text2PDF.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|