|
VC++.net,excel 2000,
at first I import the lib as below#import "p:\ofc2000\program files\microsoft office\office\mso9.dll" no_namespace rename("DocumentProperties", "DocumentPropertiesXL")
#import "p:\ofc2000\program files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb" no_namespace
#import "p:\ofc2000\program files\microsoft office\office\excel9.olb" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename("DocumentProperties", "DocumentPropertiesXL") no_dual_interfaces
//#import "P:\ofc97\MSAPPS\VBA\vbeext1.olb" no_namespace
#pragma warning (disable:4192)
And the I open an exsiting spread sheet:
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"Excel.Application", &clsid);
if(FAILED(hr))
{
::MessageBox(NULL, "CLSIDFromProgID() failed", "Error", 0x10010);
return;
}
IDispatch *pXlApp;
hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&pXlApp);
pXL.GetActiveObject(L"Excel.Application");
pXL.CreateInstance(L"Excel.Application");
pXL->Visible = VARIANT_TRUE;
pBook=pXL->Workbooks->Open(_T("H:\\xxs\\c++\\geopro\\Print2excel\\P2E\\Geofoam_Slope_Program.xls"));
DWORD aa=::GetLastError();
//Get the Second sheet.
pSheets = pBook->GetSheets();
pSheet = pSheets->GetItem(COleVariant(short(2)));
no error in compile and link,,
error occurs in running, I can open the spread sheet,problem comes from getting the second page of the sheets:GetItem(COleVariant(short(2)));
but this code can run in VC6.0 very well,and error comes from VC++.net,
Why??
Thank you, any suggestion is admired?
asfazxdfvzxvcxzcv
|
|
|
|
|
When you say "error comes from VC++.net", do you mean you're just getting an error when executing that last line 'pSheet = pSheets....'?
I'm assuming that you've cut and pasted some of the code, since it's not exactly clear why you're doing GetActiveObject and CreateInstance
By error, can you be more specific? Since you're using wrapper classes, rather than raw interfaces, any failure will be throwing a _com_error& exception. Can you catch this and interrogate it to try and get more error information? That would probably help the diagnosis.
Steve S
Developer for hire
|
|
|
|
|
Hey,
I am trying to get my menu that I created to show up on a dialog box. I can do it on the document based ones, but that was a long time ago, and can't remember how to do it.
Does anyone have any tutorials on how to create a basic menu? I have found some tuts with many advanced features and don't need all that stuff.
Thanks
|
|
|
|
|
Create the menu in Resource Editor. Add it to the dialog window via SetMenu().
Kuphryn
|
|
|
|
|
Could you perhaps eleborate on the SetMenu() function a bit?
|
|
|
|
|
SetMenu() takes a pointer to a CMenu object. That is it. Declare a CMenu object as the dialog window's member.
Kuphryn
|
|
|
|
|
ok, so i create a menu, go to the class wizard and it asks me to make a new class, so lets say i name it DEPMenu, I then go to the init function of the dialog and type
SetMenu(?);
the ? means what exactly goes inside of it?
|
|
|
|
|
Am i missing something?
If you have the ID of the menu like IDR_MENU1 set it at the Dialog Properties->Menu
|
|
|
|
|
Hallo,
I want to select an item from a list as the list is showed.
I tried to use: m_list.SetItemState (1,LVIS_SELECTED, LVIS_OVERLAYMASK ); but I failed. how can I do it?
thanks in advance!
Dada
|
|
|
|
|
dadacncn wrote:
m_list.SetItemState (1,LVIS_SELECTED, LVIS_OVERLAYMASK );
To select:
<br />
m_list.SetItemState (1,LVIS_SELECTED, LVIS_SELECTED); <br />
To unselect:
<br />
m_list.SetItemState (1,0, LVIS_SELECTED); <br />
|
|
|
|
|
Hi!
I´m trying to capture key messages from within a prop page.
What I did is to put an onkeydown message handler in the page where I wish to capture the key from. But it doesn´t work.
I used this method in a the view of a Document View App and it worked fine.
How does the property sheet deal with this kind of messages.
Do I have to disable all the controls within the page?
thanks in advance.
Daniel Cespedes
"There are 10 types of people, those who understand binary and those who do not"
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Prop pages contain controls (which are normaly derived from a window). Therefore, the individual controls are getting the OnKeyDown messages not the parent window (a.k.a. Prop page). If you wish to will either need to install a hook when the prop window is created (uninstall when window closes), or subclass all those controls. Recommend you look at the articles on hooking at CP and else where.
INTP
|
|
|
|
|
Thanks John, now I have a better idea about what I have to do.
Daniel Cespedes
"There are 10 types of people, those who understand binary and those who do not"
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Hello,
i use BITMAP Structure to read image data. as you know bmBits is LPVOID !
I do not know how can access to Array of image data ?
for example i try to declare array such this,
unsigned char *m_pData = new(unsigned char[BM.bmHeight*BM.bmWidth]);
and then Use m_pData = bmBits;(cuase error because bmBits is LPVOID).
thanks for your attention.
I hope hear from you.
|
|
|
|
|
Seems like you should have something like:
CFile fileBitmap(...);
BITMAPFILEHEADER rBitmapFileHeader;
BITMAPINFOHEADER rBitmapInfoHeader;
fileBitmap.Read(&rBitmapFileHeader, sizeof(BITMAPFILEHEADER));
fileBitmap.Read(&rBitmapInfoHeader, sizeof(BITMAPINFOHEADER));
fileBitmap.Seek(rBitmapFileHeader.bfOffBits, CFile::begin);
unsigned char *m_pdata = new unsigned char[rBitmapInfoHeader.biWidth * rBitmapInfoHeader.biHeight];
fileBitmap.Read(m_pData, rBitmapInfoHeader.biWidth * rBitmapInfoHeader.biHeight);
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
You Mean there is now way to convert Long Pointer and declare array that point to that location in memory?
And i must read bitmap file .
there is somethings that when Bitmap compressed how can i read right Image data.
thanks for your attention.
best wishes.
|
|
|
|
|
mostafa_pasha wrote:
You Mean there is now way to convert Long Pointer and declare array that point to that location in memory?
And i must read bitmap file .
Yes, you must first read the data from disk into memory. At that point, you can "point" to them.
Without knowing more of what you are trying to do, I can't offer anything more helpful.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
i use OpenGL to draw 24-Bitmap Image to screen. in OpenGL image data is BGR not RGB!
so after read image data i must swap Red with Blue.
so i must access image data . i see that if my bitmap compressed and i try to read file
with iostream class and read image data , i can not convert it to raw data.
so i try use BITMAP.bmBits and copy image data to new array and then swap that.
Thanks a lot for your attention.
|
|
|
|
|
Bitmap image data is stored in (memory and file) BGR order.
INTP
|
|
|
|
|
If you wish to access the data directly, this is probably not the best method. If you apply a typecast to bmBits the error will go away but the code will still be wrong.
unsigned char* pData = (unsigned char*)bmBits;
....
if( bm.bmBits )
{
DWORD dwImageSize = bm.bmHeight * bmByteWidth;
unsigned char* pData = new unsigned char[dwImageSize];
if( pData )
{
memcpy(pData,bm.bmBits,dwImageSize);
.....
memcpy(bm.bmBits,pData,dwImageSize);
delete [] pData;
}
}
There are articles at CP on manipulating bitmaps directly as well at totorials. The book "Programming Windows" by Charles Petzold covers bitmaps and DIB Sections extensively.
Good Luck!
INTP
|
|
|
|
|
In addition to all of this, it's much easier to use a DIBSection wrapper, or use GDI+.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
thanks a lot John with best wishes for your answering..
about format of BITMAP i know if i wanna use in OpenGL i must swap R with B.
Is that right?
Christian thanks for your attention , but GDI+ is not for 3D.i use OpenGL for this
purpose so i can not use GDI+ when i Use dubbleBuffering in OpenGL.
Thanks a lot.
|
|
|
|
|
mostafa_pasha wrote:
i know if i wanna use in OpenGL i must swap R with B.
Only if OpenGL stores the bits in RGB. Windows always used BGR.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
HI everybody!
I need to know how to set the background color of a view.
I have tried using the 'SetBkColor(COLORREF color)' function but I can't get it to work.
I called the following line in the Draw function in class CView.
pDC->SetBkColor(COLORREF color);
And the background color remains white.
Can anybody tell me what to do?
_Lostris. . .
|
|
|
|