|
Hello everybody,
Right now I'm creating an opengl activex control that allows JavaScript to communicate with the control. For example:
*********************************************
function begin()
{
var object = document.SGLworld;
object.StartRender();
}
function stop()
{
var object = document.SGLworld;
object.StopRender();
}
<object classid="clsid:4E14E2C5-A05D-466D-979A-97391CB899E8" width="200" height="200" id="SGLworld">
*********************************************
I plan on having the ability to pass class or struct objects back to a JavaScript variable like this:
*********************************************
function returnclass()
{
var box;
var object = document.SGLworld;
box = object.CreateBox(1.0, 1.0, 1.0); // return the createbox structure to the javascript variable(box)
box.SetColor(1.0, 0.0, 0.0); // now the varible(box) should have access to the structers members functions
}
*********************************************
But the problem is I have no clue how to pass struct(or class) objects back to a js variable! So if anybody has an idea or can redirect to some information I’d be very grateful!!!
Thanks,
Caleb
|
|
|
|
|
Have you tried SpiderMonkey? It's the javascript engine of the Mozilla project.
|
|
|
|
|
|
I am trying to access the partition data from the hard disk but I get an error 87 (Incorrect parameter) on the read file.
typedef struct tagPARTENTRY
{
BYTE bBoot;
BYTE bHead;
BYTE bSector;
BYTE bCyl;
BYTE bSysInd;
BYTE bEndHead;
BYTE bEndSector;
BYTE bEndCyl;
UINT unStartSect;
UINT unNumSects;
} PARTENTRY;
typedef struct tagDISKTABLE
{
CHAR cData[445];
PARTENTRY peTable[4];
WORD wSignature;
} DISKTABLE;
...
INT nDriveNum = 0;
CHAR szFileName[MAX_PATH];
DISKTABLE dtBuffer;
LARGE_INTEGER liSeekPos;
...
liSeekPos.QuadPart = 0;
wsprintf(szFileName, "\\\\.\\PhysicalDrive%d", nDriveNum);
hDevice = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if (SetFilePointer(hDevice, liSeekPos.LowPart, &liSeekPos.HighPart, FILE_BEGIN) == 0xFFFFFFFF)
{
AtlTrace("Seek error %d", GetLastError());
return FALSE;
}
if (!ReadFile(hDevice, (LPVOID)&dtBuffer, sizeof(DISKTABLE), (LPDWORD) &dwBytesRead, NULL))
{
AtlTrace("Error reading from disk. error code = %d\n", GetLastError());
return FALSE;
}
...
I tried the same code by opening a file instead of a PhysicalDrive# and the ReadFile completed successfully. Any ideas?
-- I have also been able to get the geometry of the disk using the same handle. Do I need a differant type of handle or is it that I can't access the sectors on disk? I have seen DeviceIoControl commands to lock the volume, does the volume need to be locked before I can read from it?
Thanks in advance,
Clint
|
|
|
|
|
Try adding FILE_SHARE_WRITE also, even if you only open it for reading (if you think about it for a while it actually makes sense, sharing has nothing to do with the I/O direction - even that it looks wierd in this context - and the OS might want to write "last accessed time" or something). I seem to recall a problem with this.
|
|
|
|
|
Hi,
As we print to the printer, the size (will be changed according that printer resolution), there any function or class we can read the Printer resolution and adjust according in run time?
Thanks,
ATC
|
|
|
|
|
CDC::GetDeviceCaps
-c
Cheap oil. It's worth it!
|
|
|
|
|
Is there anybody who can give me code or tell me that "how can I get in array, the color values of a .bmp file after opening it(how to open for this purpose) with providing required x, y places to get specific image area in array "
I'll really be so thankful to you for your favour.
Thanks
|
|
|
|
|
Here at CP you can find Davide Pizzolato's CXImage, which does what you want (and a lot more.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
how to use combo box ?
i have one combo box on my dialog.
i write tray1 (ctrl enter) tray2 ....etc. in combo box, properties, data tab.
then i run the program. when i click on the arrow down key on combo box.. either one of whatever i typed in for data are there. it's empty. but if i click on somewhere of that empty box, the data is there. i just don't see it..
what did i do wrong so that data are invisible but there in the combo box.
|
|
|
|
|
go to the dialog editor, open the dialog with the combo box.
click the arrow on the combo and then drag the bottom of the rectangle down.
Cheap oil. It's worth it!
|
|
|
|
|
Hi all, I'm using DirectX and am trying to see whether my graphics card can use the IID_IDirect3DTnLHalDevice ref before committing my application to it (where a nasty fail would happen if it couldn't). I have used the EnumDevices Callback function to obtain a D3DEVICEDESC7 pointer and am trying to check the dwDevCaps variable for the D3DDEVCAPS_HWTRANSFORMANDLIGHT cap by using:
if (!(lpdEnumDevice->dwDevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT))
return Error;
lpdEnumDevice is the correct structure, but this test always returns false! I have tried using the IID_IDirect3DTnLHalDevice id at CreateDevice time and it works! so I know it must support it. What am I doing wrong? I have a nVidia GeForce 2 Ultra (Gainward spec) graphics card. Any ideas, views or suggestions would be very appreciated.
Ta all,
Alan.
|
|
|
|
|
Isn't this flag only useable for D3DDEVICEDESC_V1 ?
|
|
|
|
|
I developed a program as a Win 32 application (non-MFC)
But I found it very difficult to work with string but without CString (MFC). Ex: I can't find a function to cut string from 1 to m (Left()) , a function to cut string from n to m (Mid())...
Can I use this MFC class in my program without rewriting in MFC.
Can I include this MFC class (.h, .cpp) like a normal class ?
Help me !!!
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
In Settings/General choose "Use MFC in a static library"
rechi
|
|
|
|
|
And...
In stdafx.h replace #include <windows.h> with #include <afx.h>
rechi
|
|
|
|
|
I'd suggest you consider it twice and try to stick with std::string s. As for the functions you need, it's simple to write them:
std::string mid(const std::string& str,std::string::size_type n,std::string::size_type m)
{
std::string::size_type count=m<=str.size()?m-n:std::string::npos;
return str.substr(n,count);
}
std::string left(const std::string& str,std::string::size_type n)
{
std::string::size_type count=n<=str.size()?n:str.size();
return str.substr(0,count);
}
std::string right(const std::string& str,std::string::size_type n)
{
std::string::size_type count=n<=str.size()?n:str.size();
return str.substr(str.size()-count,count);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is it about the large amount of resources MFC is using?
rechi
|
|
|
|
|
The resource issue is one reason. The most important objection, though, is of a more profound nature. Adhering to a huge framework for the sake of a tiny utility class like CString can cause more harm than good: if you for instance need to port your app to a non-Win32 platform, you'll be regretting you're locked into MFC for such a minute reason. My advice is one should use MFC for what is worth --doing GUI stuff for Windows.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
that...and the fact that the original poster said "non-MFC".
-c
Cheap oil. It's worth it!
|
|
|
|
|
Instead of adding MFC, use std::string. It has a substr method which does what you're looking for.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
If you don't want to use std::string, use WTL which has a CString that works just like MFC's.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I developed a program as a Win 32 application (non-MFC)
But I find it very difficult to work with string without CString (MFC).
Can I use this MFC class in my program without rewriting my program ?
Can I include this MFC class like a normal class ?
Help me !
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
dlhson wrote:
Can I use this MFC class in my program without rewriting my program ?
no. but there are many classes available on this very site that do just about everything CString can do. or, you could use std::string.
-c
Cheap oil. It's worth it!
|
|
|
|
|
Yes you can, you just need to include MFC support. Look up this topic in MSDN.
Add MFC Support to an ATL Project
Adding MFC support to a Win32 app is similar.
|
|
|
|