|
Thanks for the help guys! I was using std instead of stlp_std, so I made the adjustment, and now it compiles fine!
I appreciate it!
|
|
|
|
|
Hi,
I can not find out how to read what is in a VARIANT, which is the result of calling a method GetAllProperties. The doc of this method only specifies that a VARIANT is returned. It should contain some kind of strings. I tried this :
VARIANT names;
_variant_t v1;
VARTYPE vtype;
long ix;
...
x->GetAllProperties(&names);
if (V_ISARRAY(&names)) {
SafeArrayGetVartype(names.parray,&vtype);
// this returns 0x0800 in vtype, so I assume it is an array of _variant_t !!!
for (ix=0;ix<nprops;ix++) {
SafeArrayGetElement(names.parray,&ix,&v1);
_bstr_t s1(v1);
printf("name=%s\n",(char *)s1);
}
}
But this ends in an exception during the statement "_bstr_t s1(v1);"
What do I do wrong ???
Linde Ackermans
|
|
|
|
|
You're assuming v1 is a string. It maybe something else (you have to check the VARIANT 's vt field). Moreover, why don't you check the SafeArrayGetElement return value?
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]
|
|
|
|
|
I did what you suggest :
the return value of SafeArrayGetElement is S_OK
v1.vt = 0x95d4
I have seen a VB example using this GetAllProperties method, and there they simply access it with names(i), and treat it as a string ( it stands for a Property Name )
How can I translate this into C++ ?
|
|
|
|
|
LindeA wrote: _bstr_t s1(v1);
In addition to checks suggested by CPallini , I suggest to you to read VARIANT's doucmentation.
If it really contains strings, it can be used as v1.bstr .
|
|
|
|
|
hi guys,
i been writing a program that connect to a remote database in speedhosting.co.cc .But i been having problem to connect its showing error when i run it...
Error message :
An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
Additional information: Unable to connect to any of the specified MySQL hosts.
below is my coding :-
#pragma once
namespace trialcpp {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace MySql::Data::MySqlClient;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ cmdLogin;
private: System::Windows::Forms::Button^ cmdExit;
protected:
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->cmdLogin = (gcnew System::Windows::Forms::Button());
this->cmdExit = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
this->cmdLogin->Location = System::Drawing::Point(52, 190);
this->cmdLogin->Name = L"cmdLogin";
this->cmdLogin->Size = System::Drawing::Size(75, 23);
this->cmdLogin->TabIndex = 0;
this->cmdLogin->Text = L"Login";
this->cmdLogin->UseVisualStyleBackColor = true;
this->cmdLogin->Click += gcnew System::EventHandler(this, &Form1::cmdLogin_Click);
this->cmdExit->Location = System::Drawing::Point(175, 190);
this->cmdExit->Name = L"cmdExit";
this->cmdExit->Size = System::Drawing::Size(75, 23);
this->cmdExit->TabIndex = 1;
this->cmdExit->Text = L"Exit";
this->cmdExit->UseVisualStyleBackColor = true;
this->cmdExit->Click += gcnew System::EventHandler(this, &Form1::Exit_Click);
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(326, 266);
this->Controls->Add(this->cmdExit);
this->Controls->Add(this->cmdLogin);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void Exit_Click(System::Object^ sender, System::EventArgs^ e) {
this->Close();
}
private: System::Void cmdLogin_Click(System::Object^ sender, System::EventArgs^ e) {
MySqlConnection ^conDatabase = gcnew MySqlConnection("DataSource = 'sql304.xxxx.xxx'; User Name='username'; Password='password'; database='database_name'");
conDatabase->Open();
System::Windows::Forms::MessageBox::Show("Connection Successful");
conDatabase->Close();
}
};
Kindly help me guys plz.. thanks a lot.
Regards,
Thilek
|
|
|
|
|
It's obviously escaped your notice that this isn't the C++/CLI forum[^] - I'd ask your question there...
|
|
|
|
|
i am new to this forum so i not sure the different between C++/MFC and C++/CLI..
Kindly explain to me plz...
|
|
|
|
|
C++/CLI = C++ for .NET
C++/MFC = C++ without using .NET
|
|
|
|
|
|
Hi everybody,
can anyone help me ?
i'm developing a MFC Dialog based app which can <u>simulate 'Windows Desktop' upto limited functionalities</u>,
using Shell API, IContexMenu etc.
While Renaming a file or folder onto desktop, all i could do is; just rename Virtual folders.
When attempting to rename normal files, folders, or link onto desktop, it renames '<b>My Computer</b>' only.
Rename operation executing into 'LVN_ENDLABELEDIT' with appropriate handler
My code snap-shot are:
<pre></pre>
void CClinckDlg::OnRenameLabelEnd(NMHDR *pNMHDR, LRESULT *pResult)
{
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
LPCWSTR pwStrNewItem = T2CW(pDispInfo->item.pszText);
LPITEMIDLIST pidlNewItem = NULL;
IShellFolder *pshFolder ;
HRESULT hr = NULL ;
SHGetDesktopFolder( &pshFolder ) ;
DWORD dwAttrFlag = SFGAO_CANRENAME;
// m_pidlOldItem was stored as current PIDL, while Right-click onto ClistCtrl item
hr = pshFolder->GetAttributesOf( 1, (LPCITEMIDLIST*)&m_pidlOldItem, &dwAttrFlag ) ;
if( ( dwAttrFlag & SFGAO_CANRENAME ) == 0 )
{
::MessageBox(NULL,
_T("IShellFolder::GetAttributesOf failed, File/Folder can not 'Rename'"),_T("Error"),MB_OK);
return ;
}
hr = pshFolder->SetNameOf(NULL, m_pidlOldItem, pwstr, /*0*/ SHGDN_FOREDITING, &pidlNewItem);
if( FAILED(hr) || (pidlNewItem==NULL) )
{
::MessageBox(NULL,
_T("IShellFolder::SetNameOf failed"),_T("Error"),MB_OK);
return ;
}
// Notify, that item has been renamed successfully
SHChangeNotify( SHCNE_RENAMEFOLDER, SHCNF_IDLIST | SHCNF_FLUSH, m_pidlOldItem, pidlNewItem ) ;
// Set the new PIDL structure
......... .........
..
pshFolder->Release() ;
}
<pre></pre>
Properties of my CListCtrl are,
View = Icon
Edit Labels = True
Thanks a lot in Advance !!
ab4rum
|
|
|
|
|
I have a feeling that SetNameOf only works for things whose identity is defined by something other than their name. That's things like the Recycle bin and My Computer, which are implemented as namespace extensions rather than through files.
I'm guessing you're meant to use SHFileOperation to rename filesystem objects like files and folders.
|
|
|
|
|
Hi Stuart,
I just got a little nudge in right direction, thanks.
As i said, i've to simulate Windows desktop to a limited set of functionalities.
However, have found some anomalies associated with SHFileOperation, for instance:
1). When desination file name given without extension,
after changing name correctly, icon abnormally changed to Windows default icon
2). So while appending for file extesion, care must be taken whether selected item is a file or a folder
as we don't, what item a user is renaming.
3). And.. for Virtual folders, because of their GUID associated as fullpath,
SHFileOperation fails. So i had to get back to my previous concept, exclusively for
renaming Virtual folders, & for non-virtuals, SHFileOperation is best.
Thanks a lot Stuart
|
|
|
|
|
Hi,
I have created one sample application, which has one parent window. There i have created one picture frame, i want to insert one child window in the place of picture frame. I am able to do that and i am able to get vertical scroll bar on dialog box.
In child dialog i calling onpaint() for creating bitmap images and check boxes, there i want to create 20 bit map images, i did that.
Whenever i have scrolled down the scroll bar, the the image which is moving up is erasing, and it is displaiyng like overlapping all the images with one another...
Can any help me to get rid out of this problem..?
Thanks
Venkatesh.
|
|
|
|
|
Venkatesh - firstly, try having a little more patience - the first post you made asking this question is still on the first page of this forum...
Your problem is probably because you aren't properly managing the scrolling - as you've added a scrollbar to a dialog, you need to manage how the viewport (i.e. the dialog window) maps onto the data you're displaying (i.e. the 20 images). That means you need to work out which images to display and where to display them.
|
|
|
|
|
Hi Stuart,
It is very urgent requirement for me, that's the reason i did like that.
Any way thanks for your suggesion.
I am using below code snippet for moving vertical scroll bar.
int nDelta;
int nMaxPos = m_rcOriginalRect.Height() - m_nCurHeight;
vscroll_clicked = TRUE;
switch (nSBCode)
{
case SB_LINEDOWN:
if (m_nScrollPos >= nMaxPos)
return;
nDelta = min(max(nMaxPos/20,5),nMaxPos-m_nScrollPos);
break;
case SB_LINEUP:
if (m_nScrollPos <= 0)
return;
nDelta = -min(max(nMaxPos/20,5),m_nScrollPos);
break;
case SB_PAGEDOWN:
if (m_nScrollPos >= nMaxPos)
return;
nDelta = min(max(nMaxPos/10,5),nMaxPos-m_nScrollPos);
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
nDelta = (int)nPos - m_nScrollPos;
break;
case SB_PAGEUP:
if (m_nScrollPos <= 0)
return;
nDelta = -min(max(nMaxPos/10,5),m_nScrollPos);
break;
default:
return;
}
m_nScrollPos += nDelta;
SetScrollPos(SB_VERT,m_nScrollPos,TRUE);
ScrollWindow(0,-nDelta);
And i am using below code snippet in ONPaint() funcion, for drawing images.
CPaintDC dc(this); // device context for painting
HBITMAP m_Bmap;
CRect rect;
HDC memdc;
CString m_ifilename1,m_ifilename2;
m_ifilename2 = "C:\\Venkatesh\\Sample1.bmp";
GetClientRect(&rect);
m_Bmap=(HBITMAP)::LoadImage(NULL,m_ifilename2,IMAGE_BITMAP,600,39,LR_LOADFROMFILE | LR_DEFAULTSIZE) ;
memdc=::CreateCompatibleDC(dc.m_hDC);
::SelectObject(memdc,m_Bmap);
BitBlt(dc.m_hDC,70,180,rect.right,rect.bottom,memdc,0,0,SRCCOPY);
m_Bmap=(HBITMAP)::LoadImage(NULL,m_ifilename2,IMAGE_BITMAP,600,39,LR_LOADFROMFILE | LR_DEFAULTSIZE) ;
memdc=::CreateCompatibleDC(dc.m_hDC);
::SelectObject(memdc,m_Bmap);
BitBlt(dc.m_hDC,70,500,rect.right,rect.bottom,memdc,0,0,SRCCOPY);
DeleteObject(m_Bmap);
DeleteObject(memdc);
I think based on this code you should be able to understand my problem
|
|
|
|
|
You need to offset the rectangle into which you're blitting by m_nScrollPos.
So, something like:
BitBlt(dc.m_hDC,70,180,rect.right,rect.bottom,memdc,0,0,SRCCOPY);
would become something like
BitBlt(dc.m_hDC,70,180-m_nScrollPos,rect.right,rect.bottom-m_nScrollPos,memdc,0,0,SRCCOPY);
Also - I don't think you should be using rect.bottom - that should be m_rcOriginalRect.bottom - you want to blit the images to fit into the original window size, not the current window size?
I've replicated your problem, anyway, before using this to fix it. Here's my paint code. I use CImage objects to hold the image (CImage isn't available in VC6 before you ask) and CRect s to hold sizes. baseSize_ is equivalent to your m_OriginalHeight , while offset_ contains the current scroll position. The images are being blitted to each fill half of the original window size. This code works, anyway.
PAINTSTRUCT ps;
CDC* paintDC = BeginPaint(&ps);
CRect rcImage1(baseSize_);
rcImage1.bottom /= 2;
CRect rcImage2;
rcImage2.SubtractRect(baseSize_, rcImage1);
rcImage1.OffsetRect(-offset_);
rcImage2.OffsetRect(-offset_);
image1_.StretchBlt(*paintDC, rcImage1, SRCCOPY);
image2_.StretchBlt(*paintDC, rcImage2, SRCCOPY);
EndPaint(&ps);
HTH!!!
|
|
|
|
|
Hi Stuart,
I am not able to understand the code snippet what you have given,Can you please explain me clearly..?
Thanks
Venkatesh.
|
|
|
|
|
PAINTSTRUCT ps;
CDC* paintDC = BeginPaint(&ps);
CRect rcImage1(baseSize_);
rcImage1.bottom /= 2;
CRect rcImage2;
rcImage2.SubtractRect(baseSize_, rcImage1);
rcImage1.OffsetRect(-offset_);
rcImage2.OffsetRect(-offset_);
image1_.StretchBlt(*paintDC, rcImage1, SRCCOPY);
image2_.StretchBlt(*paintDC, rcImage2, SRCCOPY);
EndPaint(&ps);
It's a lot neater when you use utility classes like CRect and CPoint rather than just using int s - and this approach would be easy to generalise to the case where you have a horizontal scrollbar as well.
|
|
|
|
|
Hi Stuart,
Thanks a lot for provide me the code snippet with neat explanation. But still i have small doubt.
what is this baseSize_..? What data i have pass to this variable..?
what is -offset_..? and offset_ ..?how to declare this variables..?
and my images are in one location, how to pass that location information to these image variables..?
Can you please give me answer for my questions..?
Thanks in advance..
Thanks
Venkatesh.
|
|
|
|
|
As I said in my earlier message:
Stuart Dootson wrote: baseSize_ is equivalent to your m_OriginalHeight, while offset_ contains the current scroll position
You already have these variables, just with different names.
-offset_ ? As I said, offset_ is a CPoint - read the MFC documentation! What do you think -offset_ might mean....
venki502 wrote: my images are in one location, how to pass that location information to these image variables
No idea what you mean by that.
|
|
|
|
|
Hi Stuart,
Thanks for your patience, please don't mind any thing, because i am new to this environment, that's the reason i am posing more questions.
As i told you, i need to display bitmap images on dialog box.
I have images on C:\, now i need to display images from there..
image1_.StretchBlt(*paintDC, rcImage1, SRCCOPY);
image2_.StretchBlt(*paintDC, rcImage2, SRCCOPY);
Current i am working in VC6.0 version. As u mentioned in prevoius forum that CImage is not available in VC6.0.
Now how i have to give the path to these two variables.
Thanks in advance.
Thanks
Venkatesh.
|
|
|
|
|
You already had the image loading code - that's fine. The BitBlt calls were fine as well - you just need to unpack the rcImagen members into the appropriate parameters - here's how with rcImage1 :
m_ifilename2 = "C:\\Venkatesh\\Sample1.bmp";
m_Bmap=(HBITMAP)::LoadImage(NULL,m_ifilename2,IMAGE_BITMAP,600,39,LR_LOADFROMFILE | LR_DEFAULTSIZE) ;
memdc=::CreateCompatibleDC(dc.m_hDC);
::SelectObject(memdc,m_Bmap);
BitBlt(dc.m_hDC,rcImage.left,rcImage1.top,rcImage1.right,rcImage1.bottom,memdc,0,0,SRCCOPY);
|
|
|
|
|
Hi Stuart,
Thanks for you quick response on this.. Based on your suggestions i am using below code snippet in my application.
I have written this code in OnPaint function.
CPaintDC dc(this); // device context for painting
PAINTSTRUCT ps;
CDC* paintDC = BeginPaint(&ps);
CRect rcImage1(baseSize_t);
rcImage1.bottom /= 2;
CRect rcImage2;
rcImage2.SubtractRect(baseSize_t, rcImage1);
rcImage1.OffsetRect(-offset_);
rcImage2.OffsetRect(-offset_);
HBITMAP m_Bmap;
HDC memdc;
CString m_ifilename1,m_ifilename2;
m_ifilename2 = "C:\\Venkatesh\\Sample1.bmp";
m_Bmap=(HBITMAP)::LoadImage(NULL,m_ifilename2,IMAGE_BITMAP,600,39,LR_LOADFROMFILE | LR_DEFAULTSIZE) ;
memdc=::CreateCompatibleDC(dc.m_hDC);
::SelectObject(memdc,m_Bmap);
BitBlt(dc.m_hDC,rcImage1.left,rcImage1.top,rcImage1.right,rcImage1.bottom,memdc,0,0,SRCCOPY);
DeleteObject(m_Bmap);
DeleteObject(memdc);
I have declared two variables like below mentioned way:
CRect baseSize_t;
CPoint offset_;
I have assigned baseSize_t like baseSize_t = m_rcOriginalRect;
Now i able to compile this program successfully. But i am not able to get any image on the dialog box. So immediately i have debugged the app and came to know that rcImage1 and rcImage 2 are containing some garbage values like this:-
rcImage1 :- top = 842150480,bottom=84215089,left=842150454,right=842151261.
the same thing happened for rcImage2 also...
Based on above code can you please tell me, where i did wrong..?
Thanks
Venkatesh.
|
|
|
|
|
venki502 wrote: I have assigned baseSize_t like baseSize_t = m_rcOriginalRect;
Have you checked its value looks OK? What about offset_ - what have you set that to?
|
|
|
|
|