|
Hey Heath,
The function that I created on the main.aspx.cs page can be accessed from user.ascx.cs page, I don't have any problem with that. In traditional .asp pages I could just create a variable called pageStatus = "main" on the main.asp page and the user.ascs page would be an include file which would hold my flash application that have status = <%pageStatus%>, so if I went to home.asp page, the home.asp page would have pageStatus="home" and the services.asp page would have pageStatus="services". So in my flash application anytime you would go a page it would display the value of that page accordingly. Sorry, if I sound frustrated, doing some of the simpliest things in asp is a little more difficult in asp.net. I wrote this function out of frustration, I know there is a simpler way to do it. Thanks a lot in advance!
public string pageStatus()
{
string strURL = Request.ServerVariables["URL"];
StringBuilder replaceFunc = new StringBuilder(strURL);
strURL = replaceFunc.Replace("/web_isotope/","").ToString();
strURL = replaceFunc.Replace(".aspx","").ToString();
return strURL;
}
Also can I inheret the class from my main.aspx.cs page in the user.ascs.cs page.
Thanks again.
Jaime
|
|
|
|
|
How does one paint on a tree view? It turns out that if I make a user control based on treeview, events such as OnFocus, etc, do occur, but OnPaint and such don't ever occur.
I've done plenty of graphics / graph drawing using MFC and GDI++, so the problem is simply, how do I get the OnPaint event to occur? forcing a redraw doesn't seem to trigger it. It doesn't even get called the first time the control becomes visible.
|
|
|
|
|
The TreeView 's OnPaint handler is overridden so that it is not called (this is actually done in WndProc ). As I mentioned earlier (perhaps not to you, but I do say this all the time), most of the classes in System.Windows.Forms are just wrappers for common controls. Painting is only performed / allowed for controls that need to do custom painting in .NET. Otherwise, pretty much all properties you change an all methods you call actually set styles, send or post messages, and call native functions on an HWND that represents the common control.
This goes for the TreeView - no painting is required because the underlying control is already doing everything.
Instead - and I've done this on many occassions with success - override WndProc in your derivitive tree class and for Message.Msg 15 (WM_PAINT ) call the OnPaint method. You should also call SetStyle with the appropriate ControlStyles in your constructor to make sure that painting is handled correctly. In your WndProc override, be sure to call base.WndProc to allow the default implementation to handle everything you don't (which is quite a bit when you consider the whole class hierarchy).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank you very much, this explains a lot.
It sounds like it may be better to just stick with MFC for now... I thought maybe .NET Forms (With C#) would be some step up from old fragile-feeling MFC, but now they are looking more and more like a somewhat inconsistent wrapper around the old MFC code, which is more powerful anyway... so its more like a step down, in many ways.
|
|
|
|
|
Yeah, well, WinForms is the least advanced part of .NET. They're planning to add some stuff in .NET 2.0, and then .NET 3.0 will use Avalon. But right now it's not all that powerful (although it really isn't that bad either).
|
|
|
|
|
No, both MFC and Windows Forms are wrappers around common controls. All MFC is just a wrapper for native methods anyway.
You'd have to do the same thing in MFC with messages. The only major difference is that MFC can include the appropriate header files and use the structures, messages, and notifications, as well as any other native functions. With Windows Forms, you have to create the necessary structures, define the messages and notifications as either consts or enums, and P/Invoke the necessary native functions (like SendMessage is a common one you need to P/Invoke). Besides that, it's really no different. You still handle certain notification messages and use SendMessage to send messages with the appropriate arguments to the appropriate handle (which you can get from controls through Controls.Handle ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi, I recently installed the october edition of MSDN Library and I tried to look up something like IMediaDet in it and it had almost no available information. This is weird because I thought I remember in an older one that it had all sorts of DirectX 9.0 information and Managed DirectX information too, it seems like every newer version I install has less and less info, why is that?
|
|
|
|
|
For one, DirectX code is still changing and that means documentation will change with it. Also, the Summer 2003 updated some DirectX-specific documentation that may not have made it to the most recent MSDN Library (October 2003). If you really think this is a problem, this forum isn't the right place. Go to MSDN Online and email them (click the Contact Us link at the bottom).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
i downloaded this code and it's in c++. it's suppose to read the cpu temperature and display the result but i can't get it to run. can someone please massage it and make it run in c# becuase i don't know c++ that well.
thanks,
Rob Tomson
<br />
#include <iostream.h><br />
#include <windows.h><br />
#include <conio.h><br />
#define INDEX 0x295<br />
#define DATA 0x296<br />
<br />
#define BANK_SET 0x4e // lowest three bitti set a bank, in manual lk97 and lk109<br />
#define CPU_TEMP 0x50 // BANK 0 0x4e = xxxxx001<br />
#define MBM_TEMP 0x67 // 0x4e = xxxxx000<br />
<br />
int inline openIO(){<br />
HANDLE h;<br />
h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL,<br />
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);<br />
if(h == INVALID_HANDLE_VALUE) {<br />
cout << "Couldn't access giveio device\n";<br />
return 1;<br />
}<br />
CloseHandle(h);<br />
return 0;<br />
}<br />
<br />
int main(){<br />
<br />
if(openIO()) return -1;<br />
<br />
_outp(INDEX, BANK_SET);<br />
_outp(DATA, _inp(DATA)|0x01);<br />
<br />
_outp(INDEX, CPU_TEMP);<br />
cout << "CPU temp: " << _inp(DATA) << "C\n";<br />
_outp(INDEX, BANK_SET);<br />
_outp(DATA, _inp(DATA)&0xf8);<br />
_outp(INDEX, MBM_TEMP);<br />
cout << "MBM temp: " << _inp(DATA) << "C\n";<br />
<br />
return 0;<br />
}
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
This is not C++.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Guy Incognito wrote:
That was my first reaction too, but cout is definatelly C++.
yeah, that is. I reckon the rest is some custom library, or assembler. I dunno enough assembler to be sure either way.
Guy Incognito wrote:
Perhaps it is not even possible to perform this task if the .NET Framework does not support such file information. Am I right?
I can't see the code now, but it looked like it was polling a port for an external device from memory. In theory I think you can call functions to do that by loading the dll, assuming they exist. But I'd go the COM interop route personally.
Guy Incognito wrote:
Wrap the function in a COM DLL and generate an interop assembly.
Yeah, that's what I'd do. I didn't really think about it before, sorry.
Guy Incognito wrote:
Sorry. Push-ups for you...
Not sure why, but fine, they'll do me good. )
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
sorry i forgot to check the box that says 'Do not treat <'s as HTML tags'
here's what it was:
#include <iostream.h>
#include <windows.h>
#include <conio.h>
and this is suppose to be code to read the cpu temp from a winbod W83697HF/F chip. so if i can't get this converted to c# can someone help me make it work in c++?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
Or just type < for < and > for >.
You won't be able to get this to work in C# because it's too low-level for what the framework allows (not C#, since it's just a language that compiled to IL and targets the CLR).
Your best bet is to go to the manufacturer site for your mobo or cpu. You're answers should be there. As Christian mentioned, either put this code in a COM dll or as an export function in a simple DLL that you can P/Invoke. Either way works, but the latter doesn't require registration.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there a way of coloring the scrollbars of the list view?
Also is there a way of using only the vertical scrolling without the horizontal ?
Thanx in Advance
compubaby
|
|
|
|
|
The answer to both questions (though the second may not be possible) is to override WndProc and handle the Windows messages yourself (calling base.WndProc for the default implementation when desired). See the Platform SDK for more information on the list view common control and its related messages, notifications, and styles.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
I have a few general questions about how to go about implementing sounds in my application.
I have created a dictionary program with english and spanish words. It uses an Access database to store the dictionary information.
I want to record sound clips of all of the spanish words (about 600 of them), and allow the user to push a button to hear the pronunciation of the word. First of all, does anyone have any opinions on what the best way to implement sound would be. Should I use wav files and use the playsound from the Windows API, or should I use DirectSound, or should I try something else like the nBASS library? I basically just want the easiest way to play sounds, and I don't want to take up too much space on the user's computer.
Also, would it be best to embed the sounds in the database, or to have them as external files in the application folder?
Any suggestions would be helpful. Thanks!
Blake
|
|
|
|
|
Any of those libraries deal with WAV files, and your WAV files will pretty much be the same size depending on recording quality. As we discussed before, if you want to decrease the size you'll need to encode them as MP3s, OGGs, WMAs, or whatever.
As far as storing them in the database, it's just my opinion that this would add a lot of complexity because you have to (in most cases) get a "pointer" to the data and use a stream to save the file (perhaps just to memory) so that it could be played. Perhaps there's an easier way, but simplying playing a persistent file would be easier. In either case, the file will take up about the same amount of room. The database (at least Access) won't compress the contents, so it would be the same size in the database that it would be on disk. The only difficulty with the disk approach is that your database probably shouldn't store absolute paths (to work in any case and in any location) so your program should resolve the path to the same file. For instance, lets say you store the path relative to the application's installation directory. You could then do a simple Path.Combine :
string relpath = path_from_database;
string path = Path.Combine(Application.StartupPath, relpath);
PlaySound(path);
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for the information.
The main reason that I thought about storing the sounds in the database is to keep from having 600 individual wav files in the application folder, so that it seems neater. Do you think this would matter at all?
Blake
|
|
|
|
|
Not really, no. NTFS does a lot better job of many files in a directory. Overall, I would think, it'd still be faster than having to stream BLOBs froma database. I've never done this myself, though (never had a reason to), and have only read about it for the SQL classes (presume that OLE DB would be a little more cumbersome because it's generic - if even possible).
As far as the "application folder", I would create a subdirectory (if you choose this approach) to hold them so it doesn't clutter the application directory itself. This is pretty common in a lot of applications (take Office and its directory structure, for example).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
NTFS does a lot better job of many files in a directory.
As long as that many is below 10000, after that it starts choking...
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
blakeb_1 wrote:
I want to record sound clips of all of the spanish words (about 600 of them),
I suggest as Heath said a database would be good, seeing that maintainance will be easier.
Another option is to make a binary container file with a header specifying offsets to the soundfiles. nBASS allows you to play a sound clip straight from a MemoryStream.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
What should I search for to find good references for doing this?
|
|
|
|
|
nBASS[^] (you'll notice that leppie wrote it)
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Actually I was talking about information for making a binary container file. Is this the actual name for these types of files. I searched for it in Google but couldn't find anything that looked like it was a way to store all the sounds in one file. I'm just trying to find a reference for making a binary container file.
Blake
|
|
|
|
|
As leppie was saying, it's just a file with offsets - your typical archive type file. You could have a structure as the first blob in the file like so:
public struct Header
{
public int count;
public FileHeader[] headers;
}
public struct FileHeader
{
public string Filename;
public long Offset;
public long Length;
} You fill the Header structure with information, such as how many files are in the archive and an array that represents each file. You can provide a filename (might as well) and a byte offset to where that file is found. You can get a lot more advanced than this, and even this basic example wouldn't work as well as many others out there.
Basically, though, you take that offset (either from the beginning of the file (offset 0) or from the end of the Header (offset == size of Header , including the array of FileHeader s), and start reading a byte array from that Offset until Length bytes has been read.
There is no standard way of doing this, but I do remember seeing a couple of articles about archives here on CP. You could try googling for keywords such as archive, header, and other stuff I've used here. leppie might have some other suggestions.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|