1
0
Fork 0

Windows: Refactor: move guid generation to fn

This commit is contained in:
Mirko Covizzi 2020-06-08 23:02:42 +02:00
parent 2d4db1575d
commit 9324b1b129

View file

@ -29,17 +29,11 @@ unsafe fn message_box(title: &str, msg: &str) {
); );
} }
pub struct Window; unsafe fn generate_guid() -> String {
impl Window {
// todo: we should decide this interface
pub fn open(options: WindowOpenOptions) -> Self {
unsafe {
// We generate a unique name for the new window class to prevent name collisions
let mut guid: GUID = std::mem::zeroed(); let mut guid: GUID = std::mem::zeroed();
CoCreateGuid(&mut guid); CoCreateGuid(&mut guid);
let class_name = format!( format!(
"Baseview-{:0X}-{:0X}-{:0X}-{:0X}{:0X}-{:0X}{:0X}{:0X}{:0X}{:0X}{:0X}\0", "{:0X}-{:0X}-{:0X}-{:0X}{:0X}-{:0X}{:0X}{:0X}{:0X}{:0X}{:0X}\0",
guid.Data1, guid.Data1,
guid.Data2, guid.Data2,
guid.Data3, guid.Data3,
@ -51,7 +45,17 @@ impl Window {
guid.Data4[5], guid.Data4[5],
guid.Data4[6], guid.Data4[6],
guid.Data4[7] guid.Data4[7]
); )
}
pub struct Window;
impl Window {
// todo: we should decide this interface
pub fn open(options: WindowOpenOptions) -> Self {
unsafe {
// We generate a unique name for the new window class to prevent name collisions
let class_name = format!("Baseview-{}", generate_guid());
let wnd_class = WNDCLASSA { let wnd_class = WNDCLASSA {
// todo: for OpenGL, will use it later // todo: for OpenGL, will use it later